Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open & run a workbook macro.
I have a source wb, with the following code in a code module:
Dim vPath As String Dim vWBOpenDataFileName As String Sub OpenDataFile() vPath = ActiveWorkbook.Path vWBOpenDataFileName = "DJ Sales Data Import macro for Judith.xls" Workbooks.Open vPath & "\" & vWBOpenDataFileName Debug.Print Application.Run("[" & vWBOpenDataFileName & "]!OpenDJSalesData") Stop End Sub It should open another wb called "DJ Sales Data Import macro for Judith.xls", and run the macro "OpenDJSalesData". But I get the error "Runtime error 1004: A document with the name "DJ Sales Data Import macro for Judith.xls" is already open. You can not open two documents with the same name, even if they are in different folders........". This error occurrs on the Debug.Print line. Why is this happening? WinXP SP1, XL2002. -- Julian Milano |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open & run a workbook macro.
Julian,
Try this slightly amended version Change Debug.Print Application.Run("[" & vWBOpenDataFileName &"]!OpenDJSalesData") to Debug.Print Application.Run(vWBOpenDataFileName & "!OpenDJSalesData") -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Julian Milano" wrote in message ... I have a source wb, with the following code in a code module: Dim vPath As String Dim vWBOpenDataFileName As String Sub OpenDataFile() vPath = ActiveWorkbook.Path vWBOpenDataFileName = "DJ Sales Data Import macro for Judith.xls" Workbooks.Open vPath & "\" & vWBOpenDataFileName Debug.Print Application.Run("[" & vWBOpenDataFileName & "]!OpenDJSalesData") Stop End Sub It should open another wb called "DJ Sales Data Import macro for Judith.xls", and run the macro "OpenDJSalesData". But I get the error "Runtime error 1004: A document with the name "DJ Sales Data Import macro for Judith.xls" is already open. You can not open two documents with the same name, even if they are in different folders........". This error occurrs on the Debug.Print line. Why is this happening? WinXP SP1, XL2002. -- Julian Milano |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open & run a workbook macro.
Try this ( you might need to ensure the OpenDJSalesData macro is define
as Public ) - Dim vPath As String Dim vWBOpenDataFileName As String Sub OpenDataFile() Dim wbkSalesDataMacro As Workbook vPath = ActiveWorkbook.Path vWBOpenDataFileName = "DJ Sales Data Import macro for Judith.xls" Set wbkSalesDataMacro = Workbooks.Open(vPath & "\" vWBOpenDataFileName) Debug.Print wbkSalesDataMacro.OpenDJSalesData Stop End Su -- Message posted from http://www.ExcelForum.com |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open & run a workbook macro.
Bob,
I got the error "Error 1004: The macro 'DJ Sales Data Import macro for Judith.xls!OpenDJSalesData' can not be found." Note that the macro I am trying to run is in a code module called "mMain". -- Julian Milano "Bob Phillips" wrote in message ... Julian, Try this slightly amended version Change Debug.Print Application.Run("[" & vWBOpenDataFileName &"]!OpenDJSalesData") to Debug.Print Application.Run(vWBOpenDataFileName & "!OpenDJSalesData") -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Julian Milano" wrote in message ... I have a source wb, with the following code in a code module: Dim vPath As String Dim vWBOpenDataFileName As String Sub OpenDataFile() vPath = ActiveWorkbook.Path vWBOpenDataFileName = "DJ Sales Data Import macro for Judith.xls" Workbooks.Open vPath & "\" & vWBOpenDataFileName Debug.Print Application.Run("[" & vWBOpenDataFileName & "]!OpenDJSalesData") Stop End Sub It should open another wb called "DJ Sales Data Import macro for Judith.xls", and run the macro "OpenDJSalesData". But I get the error "Runtime error 1004: A document with the name "DJ Sales Data Import macro for Judith.xls" is already open. You can not open two documents with the same name, even if they are in different folders........". This error occurrs on the Debug.Print line. Why is this happening? WinXP SP1, XL2002. -- Julian Milano |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open & run a workbook macro.
Julian,
Well at least it has moved forward<vbg. As long as the macro exists, is not private, and is in a standard code module, you should find it. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Julian Milano" wrote in message ... Bob, I got the error "Error 1004: The macro 'DJ Sales Data Import macro for Judith.xls!OpenDJSalesData' can not be found." Note that the macro I am trying to run is in a code module called "mMain". -- Julian Milano "Bob Phillips" wrote in message ... Julian, Try this slightly amended version Change Debug.Print Application.Run("[" & vWBOpenDataFileName &"]!OpenDJSalesData") to Debug.Print Application.Run(vWBOpenDataFileName & "!OpenDJSalesData") -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Julian Milano" wrote in message ... I have a source wb, with the following code in a code module: Dim vPath As String Dim vWBOpenDataFileName As String Sub OpenDataFile() vPath = ActiveWorkbook.Path vWBOpenDataFileName = "DJ Sales Data Import macro for Judith.xls" Workbooks.Open vPath & "\" & vWBOpenDataFileName Debug.Print Application.Run("[" & vWBOpenDataFileName & "]!OpenDJSalesData") Stop End Sub It should open another wb called "DJ Sales Data Import macro for Judith.xls", and run the macro "OpenDJSalesData". But I get the error "Runtime error 1004: A document with the name "DJ Sales Data Import macro for Judith.xls" is already open. You can not open two documents with the same name, even if they are in different folders........". This error occurrs on the Debug.Print line. Why is this happening? WinXP SP1, XL2002. -- Julian Milano |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open & run a workbook macro.
Guys,
What I've found is that if I use this line: Debug.Print Application.Run("DJ Sales Data Import macro for Judith.xls!OpenDJSalesData") ..... I get the macro-can't-be-found error. But if I use the following line: Debug.Print Application.Run("DJSalesDataImportmacroforJudith.x ls!OpenDJSalesData") .....ie. with no spaces (and with the workbook saved under the new name), it works. So, my next question is....How do I run a macro in another workbook, where the workbook name contains spaces?? XL2002 on WinXP SP1. -- Julian Milano "Bob Phillips" wrote in message ... Julian, Well at least it has moved forward<vbg. As long as the macro exists, is not private, and is in a standard code module, you should find it. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Julian Milano" wrote in message ... Bob, I got the error "Error 1004: The macro 'DJ Sales Data Import macro for Judith.xls!OpenDJSalesData' can not be found." Note that the macro I am trying to run is in a code module called "mMain". -- Julian Milano "Bob Phillips" wrote in message ... Julian, Try this slightly amended version Change Debug.Print Application.Run("[" & vWBOpenDataFileName &"]!OpenDJSalesData") to Debug.Print Application.Run(vWBOpenDataFileName & "!OpenDJSalesData") -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Julian Milano" wrote in message ... I have a source wb, with the following code in a code module: Dim vPath As String Dim vWBOpenDataFileName As String Sub OpenDataFile() vPath = ActiveWorkbook.Path vWBOpenDataFileName = "DJ Sales Data Import macro for Judith.xls" Workbooks.Open vPath & "\" & vWBOpenDataFileName Debug.Print Application.Run("[" & vWBOpenDataFileName & "]!OpenDJSalesData") Stop End Sub It should open another wb called "DJ Sales Data Import macro for Judith.xls", and run the macro "OpenDJSalesData". But I get the error "Runtime error 1004: A document with the name "DJ Sales Data Import macro for Judith.xls" is already open. You can not open two documents with the same name, even if they are in different folders........". This error occurrs on the Debug.Print line. Why is this happening? WinXP SP1, XL2002. -- Julian Milano |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open & run a workbook macro.
Julian,
Debug.Print Application.Run("'DJ Sales Data Import macro for Judith.xls'!OpenDJSalesData") -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Julian Milano" wrote in message ... Guys, What I've found is that if I use this line: Debug.Print Application.Run("DJ Sales Data Import macro for Judith.xls!OpenDJSalesData") .... I get the macro-can't-be-found error. But if I use the following line: Debug.Print Application.Run("DJSalesDataImportmacroforJudith.x ls!OpenDJSalesData") ....ie. with no spaces (and with the workbook saved under the new name), it works. So, my next question is....How do I run a macro in another workbook, where the workbook name contains spaces?? XL2002 on WinXP SP1. -- Julian Milano "Bob Phillips" wrote in message ... Julian, Well at least it has moved forward<vbg. As long as the macro exists, is not private, and is in a standard code module, you should find it. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Julian Milano" wrote in message ... Bob, I got the error "Error 1004: The macro 'DJ Sales Data Import macro for Judith.xls!OpenDJSalesData' can not be found." Note that the macro I am trying to run is in a code module called "mMain". -- Julian Milano "Bob Phillips" wrote in message ... Julian, Try this slightly amended version Change Debug.Print Application.Run("[" & vWBOpenDataFileName &"]!OpenDJSalesData") to Debug.Print Application.Run(vWBOpenDataFileName & "!OpenDJSalesData") -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Julian Milano" wrote in message ... I have a source wb, with the following code in a code module: Dim vPath As String Dim vWBOpenDataFileName As String Sub OpenDataFile() vPath = ActiveWorkbook.Path vWBOpenDataFileName = "DJ Sales Data Import macro for Judith.xls" Workbooks.Open vPath & "\" & vWBOpenDataFileName Debug.Print Application.Run("[" & vWBOpenDataFileName & "]!OpenDJSalesData") Stop End Sub It should open another wb called "DJ Sales Data Import macro for Judith.xls", and run the macro "OpenDJSalesData". But I get the error "Runtime error 1004: A document with the name "DJ Sales Data Import macro for Judith.xls" is already open. You can not open two documents with the same name, even if they are in different folders........". This error occurrs on the Debug.Print line. Why is this happening? WinXP SP1, XL2002. -- Julian Milano |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open & run a workbook macro.
Bob,
LIFESAVER!!! -- Julian Milano "Bob Phillips" wrote in message ... Julian, Debug.Print Application.Run("'DJ Sales Data Import macro for Judith.xls'!OpenDJSalesData") -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Julian Milano" wrote in message ... Guys, What I've found is that if I use this line: Debug.Print Application.Run("DJ Sales Data Import macro for Judith.xls!OpenDJSalesData") .... I get the macro-can't-be-found error. But if I use the following line: Debug.Print Application.Run("DJSalesDataImportmacroforJudith.x ls!OpenDJSalesData") ....ie. with no spaces (and with the workbook saved under the new name), it works. So, my next question is....How do I run a macro in another workbook, where the workbook name contains spaces?? XL2002 on WinXP SP1. -- Julian Milano "Bob Phillips" wrote in message ... Julian, Well at least it has moved forward<vbg. As long as the macro exists, is not private, and is in a standard code module, you should find it. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Julian Milano" wrote in message ... Bob, I got the error "Error 1004: The macro 'DJ Sales Data Import macro for Judith.xls!OpenDJSalesData' can not be found." Note that the macro I am trying to run is in a code module called "mMain". -- Julian Milano "Bob Phillips" wrote in message ... Julian, Try this slightly amended version Change Debug.Print Application.Run("[" & vWBOpenDataFileName &"]!OpenDJSalesData") to Debug.Print Application.Run(vWBOpenDataFileName & "!OpenDJSalesData") -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Julian Milano" wrote in message ... I have a source wb, with the following code in a code module: Dim vPath As String Dim vWBOpenDataFileName As String Sub OpenDataFile() vPath = ActiveWorkbook.Path vWBOpenDataFileName = "DJ Sales Data Import macro for Judith.xls" Workbooks.Open vPath & "\" & vWBOpenDataFileName Debug.Print Application.Run("[" & vWBOpenDataFileName & "]!OpenDJSalesData") Stop End Sub It should open another wb called "DJ Sales Data Import macro for Judith.xls", and run the macro "OpenDJSalesData". But I get the error "Runtime error 1004: A document with the name "DJ Sales Data Import macro for Judith.xls" is already open. You can not open two documents with the same name, even if they are in different folders........". This error occurrs on the Debug.Print line. Why is this happening? WinXP SP1, XL2002. -- Julian Milano |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Open Workbook Macro??? | Excel Discussion (Misc queries) | |||
Run a macro when I open a workbook | Excel Discussion (Misc queries) | |||
run macro on workbook open | Excel Discussion (Misc queries) | |||
how can I run a macro when I open a workbook? | Excel Discussion (Misc queries) | |||
How to run VBA macro when the workbook is open? | Excel Programming |