|
#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 |
|
#2
|
|||
|
|||
|
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! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|