Click here to Skip to main content
15,889,116 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Problems implementing MEF Pin
Brisingr Aerowing7-Oct-15 9:15
professionalBrisingr Aerowing7-Oct-15 9:15 
GeneralRe: Problems implementing MEF Pin
Kenneth Haugland7-Oct-15 9:32
mvaKenneth Haugland7-Oct-15 9:32 
QuestionRe: Problems implementing MEF Pin
Kenneth Haugland7-Oct-15 18:57
mvaKenneth Haugland7-Oct-15 18:57 
AnswerRe: Problems implementing MEF Pin
Kenneth Haugland7-Oct-15 20:55
mvaKenneth Haugland7-Oct-15 20:55 
Questionmouse hover over button to show sliding label and don't hide it until mouse leaves the panel. Pin
Pravas Ranjan7-Oct-15 3:11
Pravas Ranjan7-Oct-15 3:11 
QuestionCompiled code cannot create Excel.Application, Interpreted is fine Pin
DAH_bham6-Oct-15 1:27
DAH_bham6-Oct-15 1:27 
AnswerRe: Compiled code cannot create Excel.Application, Interpreted is fine Pin
Richard Deeming6-Oct-15 1:49
mveRichard Deeming6-Oct-15 1:49 
GeneralRe: Compiled code cannot create Excel.Application, Interpreted is fine Pin
DAH_bham6-Oct-15 2:33
DAH_bham6-Oct-15 2:33 
The exception message was 'Cannot create ActiveX component.' I have updated the DCOM config permissions for Excel Application and restarted IIS, but still no joy

The following is all of the code behind (this page is cut down from a page that gets mountains of data - just to test the create & save excel part )


Imports CommonFunctions
Imports Microsoft.VisualBasic
Imports Microsoft.Office.Core
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Partial Class FEMain_ContractAdmin_TestExcel2
    Inherits System.Web.UI.Page
    Dim objCF As New CommonFunctions

    Protected Sub btnKPI_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnKPI.Click

        Dim xlApp As Object
        Try
            xlApp = CreateObject("Excel.Application")
        Catch ex As Exception
            objCF.logError(System.IO.Path.GetFileName(System.Web.HttpContext.Current.Request.Url.AbsolutePath) & " :: " & System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message)
            Exit Sub
        End Try

        Dim xlWorkBook As Object
        Dim xlWorksheet As Object
        Dim misValue As Object = System.Reflection.Missing.Value

        xlWorkBook = xlApp.Workbooks.Add(misValue)
        xlWorksheet = xlWorkBook.Sheets("Sheet1")
        xlWorksheet.Cells(1, 1) = "Test 123456"

        Dim strSavePath As String
        Dim strFilename As String
        Dim strFullPath As String

        strSavePath = AppDomain.CurrentDomain.BaseDirectory & "Documents\KPI\Concerns\"

        'create kpi concern directory
        If (Not Directory.Exists(strSavePath)) Then
            Directory.CreateDirectory(strSavePath)
        End If
        strFilename = "Test_" & CStr(Date.Now.Year) & objCF.addZeros(CStr(Date.Now.Month), 2) & objCF.addZeros(CStr(Date.Now.Day), 2) & "_" & objCF.addZeros(CStr(Date.Now.Hour), 2) & objCF.addZeros(CStr(Date.Now.Minute), 2) & objCF.addZeros(CStr(Date.Now.Second), 2) & objCF.addZeros(CStr(Date.Now.Millisecond), 3) & ".xlsx"
        strFullPath = strSavePath & strFilename

        'save and close
        xlWorkBook.SaveAs(strSavePath & strFilename)
        xlWorkBook.Close(True, misValue, misValue)
        xlApp.Quit()

        'release COM objects
        Call objCF.releaseObject(xlWorksheet)
        Call objCF.releaseObject(xlWorkBook)
        Call objCF.releaseObject(xlApp)

        'show the hyperlink to the excel file
        hypKPI.Visible = True
        hypKPI.NavigateUrl = "~\Documents\KPI\Concerns\" & strFilename

    End Sub

End Class

GeneralRe: Compiled code cannot create Excel.Application, Interpreted is fine Pin
Richard Deeming6-Oct-15 2:37
mveRichard Deeming6-Oct-15 2:37 
GeneralRe: Compiled code cannot create Excel.Application, Interpreted is fine Pin
Richard Deeming6-Oct-15 2:38
mveRichard Deeming6-Oct-15 2:38 
GeneralRe: Compiled code cannot create Excel.Application, Interpreted is fine Pin
Dave Kreskowiak6-Oct-15 5:14
mveDave Kreskowiak6-Oct-15 5:14 
SuggestionRe: Compiled code cannot create Excel.Application, Interpreted is fine Pin
Richard Deeming6-Oct-15 5:20
mveRichard Deeming6-Oct-15 5:20 
GeneralRe: Compiled code cannot create Excel.Application, Interpreted is fine Pin
DAH_bham6-Oct-15 3:36
DAH_bham6-Oct-15 3:36 
AnswerRe: Compiled code cannot create Excel.Application, Interpreted is fine Pin
Dave Kreskowiak7-Oct-15 4:33
mveDave Kreskowiak7-Oct-15 4:33 
QuestionStandard VB 2013 progress bar animation weirdness Pin
Member 15839634-Oct-15 8:53
professionalMember 15839634-Oct-15 8:53 
QuestionRe: Standard VB 2013 progress bar animation weirdness Pin
Brisingr Aerowing4-Oct-15 13:09
professionalBrisingr Aerowing4-Oct-15 13:09 
AnswerRe: Standard VB 2013 progress bar animation weirdness Pin
Member 15839634-Oct-15 22:16
professionalMember 15839634-Oct-15 22:16 
QuestionRe: Standard VB 2013 progress bar animation weirdness Pin
Richard MacCutchan4-Oct-15 22:02
mveRichard MacCutchan4-Oct-15 22:02 
AnswerRe: Standard VB 2013 progress bar animation weirdness Pin
Member 15839634-Oct-15 22:41
professionalMember 15839634-Oct-15 22:41 
GeneralRe: Standard VB 2013 progress bar animation weirdness Pin
Richard MacCutchan4-Oct-15 22:53
mveRichard MacCutchan4-Oct-15 22:53 
GeneralRe: Standard VB 2013 progress bar animation weirdness Pin
Member 15839635-Oct-15 2:23
professionalMember 15839635-Oct-15 2:23 
GeneralRe: Standard VB 2013 progress bar animation weirdness Pin
Richard MacCutchan5-Oct-15 3:50
mveRichard MacCutchan5-Oct-15 3:50 
AnswerRe: Standard VB 2013 progress bar animation weirdness Pin
Richard Andrew x645-Oct-15 12:10
professionalRichard Andrew x645-Oct-15 12:10 
GeneralRe: Standard VB 2013 progress bar animation weirdness Pin
Member 15839635-Oct-15 21:33
professionalMember 15839635-Oct-15 21:33 
Questionopen file location thru windows explorer Pin
Mendel Margallo Adona3-Oct-15 20:34
Mendel Margallo Adona3-Oct-15 20:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.