Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open a File and Run AutoOpen Macro
I'm trying to use workbook.open to open another file and then I want this
other file to automatically run a macro. This other macro starts by closing out the original file and then running a bunch of other code. I tried using a Workbook_Open sub but as soon as the code closes the original file it just stops running. I've tried everything I can think of but I cannot come up with a solution. I need to open a specified file, then use this file to close the original and run other code. Any ideas? Thanks Adam Bush |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open a File and Run AutoOpen Macro
If you also put a call to your Sub that you want to run in the Workbook_Open
sub it should continue on with the code. Try adding an error handler to the code and see if that doesn't help. On Error Resume Next wrote: I'm trying to use workbook.open to open another file and then I want this other file to automatically run a macro. This other macro starts by closing out the original file and then running a bunch of other code. I tried using a Workbook_Open sub but as soon as the code closes the original file it just stops running. I've tried everything I can think of but I cannot come up with a solution. I need to open a specified file, then use this file to close the original and run other code. Any ideas? Thanks Adam Bush -- Message posted via http://www.officekb.com |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open a File and Run AutoOpen Macro
Why not just have the workbook_open() event in the first workbook close that
workbook? Option Explicit Private Sub Workbook_Open() dim wkbk as workbook set wkbk = workbooks.open(filename:="s:\ome\other\work\book.x ls") me.close savechanges:=false End Sub wrote: I'm trying to use workbook.open to open another file and then I want this other file to automatically run a macro. This other macro starts by closing out the original file and then running a bunch of other code. I tried using a Workbook_Open sub but as soon as the code closes the original file it just stops running. I've tried everything I can think of but I cannot come up with a solution. I need to open a specified file, then use this file to close the original and run other code. Any ideas? Thanks Adam Bush -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open a File and Run AutoOpen Macro
Dave,
The problem is I need to close the first workbook and then continue to run code, so I can't do all this from the first workbook. Bernie, I tried your idea with the exact same results. Any more ideas? Thanks Adam Bush "Dave Peterson" wrote: Why not just have the workbook_open() event in the first workbook close that workbook? Option Explicit Private Sub Workbook_Open() dim wkbk as workbook set wkbk = workbooks.open(filename:="s:\ome\other\work\book.x ls") me.close savechanges:=false End Sub wrote: I'm trying to use workbook.open to open another file and then I want this other file to automatically run a macro. This other macro starts by closing out the original file and then running a bunch of other code. I tried using a Workbook_Open sub but as soon as the code closes the original file it just stops running. I've tried everything I can think of but I cannot come up with a solution. I need to open a specified file, then use this file to close the original and run other code. Any ideas? Thanks Adam Bush -- Dave Peterson |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open a File and Run AutoOpen Macro
You removed the code from the second workbook that closed the first workbook and
it still stopped???? I don't have another guess. wrote: Dave, The problem is I need to close the first workbook and then continue to run code, so I can't do all this from the first workbook. Bernie, I tried your idea with the exact same results. Any more ideas? Thanks Adam Bush "Dave Peterson" wrote: Why not just have the workbook_open() event in the first workbook close that workbook? Option Explicit Private Sub Workbook_Open() dim wkbk as workbook set wkbk = workbooks.open(filename:="s:\ome\other\work\book.x ls") me.close savechanges:=false End Sub wrote: I'm trying to use workbook.open to open another file and then I want this other file to automatically run a macro. This other macro starts by closing out the original file and then running a bunch of other code. I tried using a Workbook_Open sub but as soon as the code closes the original file it just stops running. I've tried everything I can think of but I cannot come up with a solution. I need to open a specified file, then use this file to close the original and run other code. Any ideas? Thanks Adam Bush -- Dave Peterson -- Dave Peterson |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open a File and Run AutoOpen Macro
Try
Workbooks.Open FileName:="whatever.XLS" ActiveWorkbook.RunAutoMacros xlAutoOpen With the file opened having a macro like so: Sub Auto_Open() 'Some code to do stuff here End Sub HTH, Bernie MS Excel MVP " m wrote in message ... I'm trying to use workbook.open to open another file and then I want this other file to automatically run a macro. This other macro starts by closing out the original file and then running a bunch of other code. I tried using a Workbook_Open sub but as soon as the code closes the original file it just stops running. I've tried everything I can think of but I cannot come up with a solution. I need to open a specified file, then use this file to close the original and run other code. Any ideas? Thanks Adam Bush |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open a File and Run AutoOpen Macro
Am I right in understanding the problem as follows?
Workbook 1 open with code opens Workbook2. Once Workbook2 opens it closes Workbook 1. If that's the case, surely the reason it stops working is that the code no longer exists because the sheet is closed. " wrote: I'm trying to use workbook.open to open another file and then I want this other file to automatically run a macro. This other macro starts by closing out the original file and then running a bunch of other code. I tried using a Workbook_Open sub but as soon as the code closes the original file it just stops running. I've tried everything I can think of but I cannot come up with a solution. I need to open a specified file, then use this file to close the original and run other code. Any ideas? Thanks Adam Bush |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open a File and Run AutoOpen Macro
Wullie,
Workbook1 opens workbook2. Workbook 2 then closes workbook1 and runs a bunch of other code. Also, after this code is run from workbook2, workbook1 is reopened and workbook 2 is closed. The whole reason for this is I want to just have workbook1 open at all times except when the code's running, however for the code to be run correct workbook1 needs to be closed for a period of time. Any ideas? Thanks Adam Bush "Wullie" wrote: Am I right in understanding the problem as follows? Workbook 1 open with code opens Workbook2. Once Workbook2 opens it closes Workbook 1. If that's the case, surely the reason it stops working is that the code no longer exists because the sheet is closed. " wrote: I'm trying to use workbook.open to open another file and then I want this other file to automatically run a macro. This other macro starts by closing out the original file and then running a bunch of other code. I tried using a Workbook_Open sub but as soon as the code closes the original file it just stops running. I've tried everything I can think of but I cannot come up with a solution. I need to open a specified file, then use this file to close the original and run other code. Any ideas? Thanks Adam Bush |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open a File and Run AutoOpen Macro
But the code exists within workbook1.
Therefore, once you open workbook2 and closed workbook1, the code no longer exists to run. Does that make sense? Can you write this code in a separate workbook that you can leave open? eg Workbook1 holds what it currently holds without the code, workbook3 holds the code - both are open. The code is run from workbook3, closes workbook1, opens workbook2, does what is required, closes workbook2 then reopens workbook1, all the while workbook3 remains open. " wrote: I'm trying to use workbook.open to open another file and then I want this other file to automatically run a macro. This other macro starts by closing out the original file and then running a bunch of other code. I tried using a Workbook_Open sub but as soon as the code closes the original file it just stops running. I've tried everything I can think of but I cannot come up with a solution. I need to open a specified file, then use this file to close the original and run other code. Any ideas? Thanks Adam Bush |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Autoopen of an Excel File at the set time | Excel Programming | |||
Open a file do a macro ( made) and open next succesive file | Excel Programming | |||
Macro to call a file that has a auto open macro in the file itself | Excel Programming | |||
'Yes' 'No' button on autoopen macro | Excel Programming |