Computing.Net > Forums > Office Software > MS-Excel VB Open Workbook

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

MS-Excel VB Open Workbook

Reply to Message Icon

Name: IroningMan
Date: July 22, 2009 at 07:53:57 Pacific
OS: Microsoft Windows XP Professional
CPU/Ram: 2.399 GHz / 2047 MB
Product: Hewlett-packard / Hp xw4400 workstation
Subcategory: General
Comment:

I am using the following syntax to open a workbook:
Application.Workbooks.Open p_file

When running this macro I get an error 4001 (Open method failed).

If I then go into debugging modus and press F8 to continue I get no further error and the macro continues to run ok.

Any ideas?

George



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: July 22, 2009 at 10:03:10 Pacific
Reply:

Not without seeing more of the code; the only error I've seen for Workbooks.Open is error 1004.


0

Response Number 2
Name: IroningMan
Date: July 22, 2009 at 10:15:38 Pacific
Reply:

You're right, of course, Error number is 1004.

What I'm doing is working in one excel-sheet, that wants to cut-and-paste a line to a second sheet.
The second sheet is not open at the time of execution.
Here the syntax surrounding the problem:
lin = rowx & ":" & rowx
Rows(lin).Select
Selection.Cut

p_file = "C:\Dokuments\JLB\Web-Site\Members_None.xls"
Application.Workbooks.Open p_file


Sheets("Members").Select
Range("a1").Select
maxl = ActiveCell.Value + 2


0

Response Number 3
Name: Razor2.3
Date: July 22, 2009 at 12:26:16 Pacific
Reply:

Step 1: Make sure "C:\Dokuments\JLB\Web-Site\Members_None.xls" exists. I assume "Dokuments" should be "Documents"
Step 2: Check the file's security to make sure you have the permissions to open it
Step 3: Make sure Excel can open the file outside of VBA.


0

Response Number 4
Name: IroningMan
Date: July 22, 2009 at 23:49:15 Pacific
Reply:

I have no problem "opening" the document.
The calling macro runs up to the "open" command and then stops with error 1004. If I then press F8 it continues without reporting any further error..
This is what bothers me... Why does it stop in the first place, only to continue on F8?


0

Response Number 5
Name: Razor2.3
Date: July 23, 2009 at 05:48:04 Pacific
Reply:

I have no problem "opening" the document.
If "Dokuments" isn't a typo, then I assume you're using the German version of Windows?

Why does it stop in the first place, only to continue on F8?
It stops because it can't open the workbook, "C:\Dokuments\JLB\Web-Site\Members_None.xls." If it does open the workbook when you press F8, then something was blocking Excel from opening the workbook, but the file lock is released by the time of your manual intervention. Does some other macro open/close the workbook? Does this macro run just before this one?


0

Related Posts

See More



Response Number 6
Name: IroningMan
Date: July 23, 2009 at 06:55:30 Pacific
Reply:

There IS another macro that opens the file, however it runs separately.
It uses the same syntax, but has no problems.
Very strange!!


0

Response Number 7
Name: Razor2.3
Date: July 23, 2009 at 12:00:35 Pacific
Reply:

Very strange indeed. This method is a bad hack, but it might get the script working again:

On Error Resume Next
Dim i As Integer
For i = 1 To 1000
  Err.Clear
  Application.Workbooks.Open "C:\Dokuments\JLB\Web-Site\Members_None.xls"
  If Err.Number = 0 Then Exit For
Next 'i
On Error GoTo 0


0

Response Number 8
Name: IroningMan
Date: July 24, 2009 at 00:16:54 Pacific
Reply:

Hey! IT WORKED!!

Thank's a lot fo that one!
Not a great leap forward for mankind, but at least I can sleep in peace again.

George


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: MS-Excel VB Open Workbook

MS Excel 2002 wont open a PDF link www.computing.net/answers/office/ms-excel-2002-wont-open-a-pdf-link/5209.html

Excel VB open hyperlink www.computing.net/answers/office/excel-vb-open-hyperlink/9364.html

MS Excel Automated Printing www.computing.net/answers/office/ms-excel-automated-printing/4683.html