how can i open a second workbook using a vba code

G

Gord Dibben

Not if you did not add more to it.

Show us the code you tried that does not work.


Gord Dibben MS Excel MVP
 
S

swain.s

this is a code from MACROS MADE EASY

Sub Workbook_Open()
Workbooks.Open("data.xls")
End Sub
 
D

Dave Peterson

Include the drive and path, too:

Workbooks.Open("c:\my folder\my other folder\data.xls")

(change as appropriate)
 
D

Dave Peterson

What happens when you try it?

Do you have macros enabled?

Are you sure that the data.xls file exists in the drive/folder you specified?

How are you opening the workbook that opens the data.xls workbook?
 
G

Gord Dibben

Have you inadvertantly disabled events?

Copy this to Immediate Window

Application.EnableEvents = True and hit Enter


Gord
 
S

swain.s

run time error '1004':
yes the macro is enabled when i open the 1st file security warning
yes they are both in the 'C:\ dir
i open test.xls manually and i want it to open data.xls automatically
 
D

Dave Peterson

Record a macro when you open that file manually. Use that code in the
workbook_Open event. (I'm guessing that you have a typo in your
drive/path/filename.)

If you have trouble modifying the workbook_open, then post the complete recorded
macro.
 
Top