Using Excel 2002 with VB.NET

M

Mitchell Vincent

Will this work if someone has office 2002 installed? :

Dim oExcel As Object
Dim wbk As Object
Dim a As String

Try
oExcel = CreateObject("Excel.Application")
Catch ex As Exception
MessageBox.Show("Microsoft Office not installed, or the version
installed is too old.", "Microsoft Office Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End Try

wbk = oExcel.Workbooks.Open(Filename:=TheExcelFile, UpdateLinks:=False,
ReadOnly:=True)

Is that an example of "late binding" ?
 
P

Peter Huang [MSFT]

Hi

Yes, this is a usage of LateBinding.

The code below will work on excel 2002.
Dim oExcel As Object
Dim wbk As Object
Dim a As String

Try
oExcel = CreateObject("Excel.Application")
Catch ex As Exception
MessageBox.Show("Microsoft Office not installed, or the version
installed is too old.", "Microsoft Office Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Exit Sub
End Try
'I add the two code below to test the code.
oExcel.Visible = True
Dim TheExcelFile As String = "c:\test.xls"
wbk = oExcel.Workbooks.Open(Filename:=TheExcelFile,
UpdateLinks:=False, ReadOnly:=True)


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top