473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using Excel 2002 with VB.NET

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" ?

--
- Mitchell Vincent
- kBilling - Invoices Made Easy!
- http://www.k-billing.com
Nov 21 '05 #1
3 1662
ng
That looks right. Do you have someone to try it out for you?

Tom

Mitchell Vincent wrote:
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" ?

Nov 21 '05 #2
ng
That looks right. Do you have someone to try it out for you?

Tom

Mitchell Vincent wrote:
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" ?

Nov 21 '05 #3
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.

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Elhanan | last post by:
hi.. i'm trying to have excel open up a webpage which basically contains a table. in excel 2000 if i specify content type text/csv this works by displaying an open/save dialog box and...
0
by: Simon Kirk | last post by:
Hi, In Access 97 I used to be able to copy data from Excel 97 and then paste it directly into the tables database pane. It would then ask if the first row contained column headings, and then...
9
by: Andi Plotsky | last post by:
I have an Access app (running under Access2000) where I want to export the data to an Excel spreadsheet. This has worked fine in the past, but after taking it to my client site (where I ran it...
4
by: Chris | last post by:
Hi, everything works apart from the last line :-(( rng.Value2.ToString() An exception is thrown : "Old format or invalid type library" It gets compiled though (so he recognizes the property...
6
by: frankplank | last post by:
Hi *, I'm wondering if it is possible to create a C# object, and reference it *explicitly* in an excel document. I imagine this will be more possible if I programmatically populate the excel...
7
by: postings | last post by:
Hi - can you help please? Please review the following straightforward code which works fine with ordinary XML files. ---------------------------------------------------------------- Dim...
4
by: jayfeb29 | last post by:
Hi , Any one can guide me in Import the Excel 2002 data into sql server 2000 using ado.net1.1. I have searched all the forums most of the solutions end with a line of suggestion not with any code...
0
by: eBob.com | last post by:
I am creating an Excel 2002 sheet programmatically using VB.Net. It all works fine. But now I'd like to add a photograph to each row. I've done searches but all the hits I get must be for VBA...
5
by: slangan | last post by:
Hi , I have a macro in excel and I am trying to run it from an access database. All works well on my machine but when I moved to another it had a problem. I have since realised that the reason is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.