Top DevX Stories
Location-Aware App Review
The Future of Web Content -- HTML5, Flash, and Mobile Apps
Moonlight 3.0 Preview Offered For Rich Internet Apps on Linux and Unix
Why a Moderator is Key in the Engineering Review Process, Part II
Windows 7 Features Your Clients Will Need on Day One
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > VB Classic

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 05-04-2004, 04:04 AM
yee68 yee68 is offline
Registered User
 
Join Date: May 2004
Posts: 1
open excel workbook from VB

I use the following code to open work book. Then would like to reference the excel work book using excelwrk.

I can't reference excelwrk as excelapp.workbooks.open("c:\test.xls") doesn't return any work book. Excelwrk is nothing.
I have no choice, have to reference worbook using excelapp.activework

Is there anything wrong with my code. Please advise. When I run application, there is no error. I am using Excel 8.0 object library.



Dim excelapp as Excel.Application
Dim excelwrk as Excel.Workbook
on error resume next

Set excelapp = GetObject(, "Excel.Application")
if err=429 then
Set excelapp = CreateObject("Excel.Application")
end if

Set excelwrk = excelapp.Workbooks.Open("c:\test.xls")

Thanks
Reply With Quote
  #2  
Old 05-04-2004, 04:53 AM
Phil Weber Phil Weber is offline
Super Moderator
 
Join Date: Nov 2003
Location: Portland, OR
Posts: 8,247
Your code works fine for me (I'm using the Excel 11.0 object library; I don't have Excel 8.0 installed).

It may be that the On Error Resume Next statement is masking a runtime error. Try commenting that line, or adding an On Error Goto 0 after the If Err = 429 Then...End If block.
__________________
Phil Weber
http://www.philweber.com

Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 11:37 AM.


Sponsored Links



Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.