Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default error opening a workbook

of ObjectHallo
Is there anybody can help me since I am new in VB and having case as follow:
I am working with two workbook where when I open the 1st workbook it will
open the second one. The problem is if the second file already open I got an
error message : Run Time Error 1004.
Methode 'OPen of Object 'Workbooks' failed

Private Sub Workbook_Open()
Workbooks.Open Filename:="O:\2009 Budget\Forecast 2008\Forecast Q Rep
08.xls" _
, UpdateLinks:=0
End Sub

Thanks for helping me

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default error opening a workbook

Maybe you can use the code at this site.

http://support.microsoft.com?kbid=138621


"budi1568" wrote:

of ObjectHallo
Is there anybody can help me since I am new in VB and having case as follow:
I am working with two workbook where when I open the 1st workbook it will
open the second one. The problem is if the second file already open I got an
error message : Run Time Error 1004.
Methode 'OPen of Object 'Workbooks' failed

Private Sub Workbook_Open()
Workbooks.Open Filename:="O:\2009 Budget\Forecast 2008\Forecast Q Rep
08.xls" _
, UpdateLinks:=0
End Sub

Thanks for helping me

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default error opening a workbook

Check to see if it's open first:

Private Sub Workbook_Open()
dim TestWkbk as workbook
set testwkbk = nothing
on error resume next
set testwkbk = workbooks("forecast q rep 08.xls") '<- no path here
on error resume next

if testwkbk is nothing then
'it's not open
set testwkbk = Workbooks.Open _
(Filename:="O:\2009 Budget\Forecast 2008\Forecast Q Rep 08.xls", _
UpdateLinks:=0)
end if

End Sub

(Untested, uncompiled--watch for typos)

budi1568 wrote:

of ObjectHallo
Is there anybody can help me since I am new in VB and having case as follow:
I am working with two workbook where when I open the 1st workbook it will
open the second one. The problem is if the second file already open I got an
error message : Run Time Error 1004.
Methode 'OPen of Object 'Workbooks' failed

Private Sub Workbook_Open()
Workbooks.Open Filename:="O:\2009 Budget\Forecast 2008\Forecast Q Rep
08.xls" _
, UpdateLinks:=0
End Sub

Thanks for helping me


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default error opening a workbook

Great!!!
Thanks Dave...really works fine


"Dave Peterson" wrote:

Check to see if it's open first:

Private Sub Workbook_Open()
dim TestWkbk as workbook
set testwkbk = nothing
on error resume next
set testwkbk = workbooks("forecast q rep 08.xls") '<- no path here
on error resume next

if testwkbk is nothing then
'it's not open
set testwkbk = Workbooks.Open _
(Filename:="O:\2009 Budget\Forecast 2008\Forecast Q Rep 08.xls", _
UpdateLinks:=0)
end if

End Sub

(Untested, uncompiled--watch for typos)

budi1568 wrote:

of ObjectHallo
Is there anybody can help me since I am new in VB and having case as follow:
I am working with two workbook where when I open the 1st workbook it will
open the second one. The problem is if the second file already open I got an
error message : Run Time Error 1004.
Methode 'OPen of Object 'Workbooks' failed

Private Sub Workbook_Open()
Workbooks.Open Filename:="O:\2009 Budget\Forecast 2008\Forecast Q Rep
08.xls" _
, UpdateLinks:=0
End Sub

Thanks for helping me


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error msg on opening excel workbook lawandgrace Excel Discussion (Misc queries) 1 February 11th 10 06:31 PM
Error msg on opening Excel Workbook lawandgrace Excel Discussion (Misc queries) 1 February 8th 10 10:27 PM
Error while opening workbook Anand Nichkaode Excel Discussion (Misc queries) 0 June 14th 08 03:18 PM
error when opening a workbook Jamie Excel Programming 0 November 7th 07 05:50 PM
Error in opening workbook [email protected] Excel Programming 7 October 17th 06 04:34 PM


All times are GMT +1. The time now is 07:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"