K
Kevryl
I know this should be the simplest thing but I'm missing something.
When I open the file "accounting.xls" I want it to open the file
"cashups.xls" automatically.
Now... I've looked up VB help and as a result I have typed in
Workbooks.Open "cashups.xls", 0
but it didnt work.
I have presumed it's typed into the window that opens when you right click
on the Excel icon and select "show code" in the main worksheet tab.
The syntax in help is unclear as always, but I don't think it requires the
brackets shown in help. I have tried them anyway, and I get an error message
saying an "=" sign is expected.
I've had a look in this thread and found a more functional method if I can
get it to work, and this is:
Dim wbk As Workbook
On Error Resume Next
Set wbk = Workbooks("Cashups.xls")
On Error GoTo 0
If wbk Is Nothing Then
MsgBox "Opening Cashups.xls now"
Set wbk = Workbooks.Open("C:\MyBook.xls")
End If
I copied and pasted this into the same window, just changing the example to
my own filename and remming out my first attempt, but it still wouldn't open
the other file.
Can someone tell me what I did wrong? Also, is there a way of doing this so
that whichever tab the "accounting.xls" file opens to the macro will still
run?
When I open the file "accounting.xls" I want it to open the file
"cashups.xls" automatically.
Now... I've looked up VB help and as a result I have typed in
Workbooks.Open "cashups.xls", 0
but it didnt work.
I have presumed it's typed into the window that opens when you right click
on the Excel icon and select "show code" in the main worksheet tab.
The syntax in help is unclear as always, but I don't think it requires the
brackets shown in help. I have tried them anyway, and I get an error message
saying an "=" sign is expected.
I've had a look in this thread and found a more functional method if I can
get it to work, and this is:
Dim wbk As Workbook
On Error Resume Next
Set wbk = Workbooks("Cashups.xls")
On Error GoTo 0
If wbk Is Nothing Then
MsgBox "Opening Cashups.xls now"
Set wbk = Workbooks.Open("C:\MyBook.xls")
End If
I copied and pasted this into the same window, just changing the example to
my own filename and remming out my first attempt, but it still wouldn't open
the other file.
Can someone tell me what I did wrong? Also, is there a way of doing this so
that whichever tab the "accounting.xls" file opens to the macro will still
run?