Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Dim exExcel As New Excel.Application

Dim exSheet As Excel.Worksheet

 

exExcel.Workbooks.Open(strFilename)

 

 

yes, the file exists, i have even tried "c:\test.xls". I am using the Excel 8.0 Objects Library

 

[edit]Dont start multiple threads on the same question[/edit]

  • Leaders
Posted

i'm using 10.0 but this may help , i think you should try setting the excel sheet as the item thats opening the app , like this :

   Dim exExcel As New Excel.Application()
   Dim exSheet As Excel.Workbook

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       exSheet = exExcel.Workbooks.Open("C:\Book1.xls")
       MsgBox(exSheet.Sheets.Count) '///just to check the excel app did open
   End Sub

Posted

------------------------------------

Option Strict Off

 

Public Class xlManager

 

Public Shared xlApp As Object

Public Shared xlBook As Object

Public Shared xlSheet As Object

 

 

 

End Class

Posted

------------------------------------

Option Strict Off

 

Public Class xlManager

 

Public Shared xlApp As Object

Public Shared xlBook As Object

Public Shared xlSheet As Object

 

sub

 

xlApp = CreateObject("Excel.Application")

'Late bind an instance of an Excel workbook.

xlBook = xlApp.Workbooks.Add

'Late bind an instance of an Excel worksheet.

xlSheet = xlBook.Worksheets(1)

xlSheet.Activate()

 

xlBook.SaveAs(strFilename)

 

end sub

 

End Class

 

------------------------------------

 

Apparently VB NET has a feature called "late-binding". Somehow that code made it work! Strange. Well, I had to go through tons of msdn articles to get it. Thank God it works and I can go on with my life :)

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...