Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Workbook Macro??? Supe Excel Discussion (Misc queries) 2 December 19th 07 08:37 PM
Run a macro when I open a workbook CraigJ Excel Discussion (Misc queries) 1 June 13th 07 04:04 PM
run macro on workbook open kevin Excel Discussion (Misc queries) 3 March 4th 05 10:12 AM
how can I run a macro when I open a workbook? filo666 Excel Discussion (Misc queries) 2 March 2nd 05 07:56 PM
How to run VBA macro when the workbook is open? Ji Wenke Excel Programming 1 July 9th 03 03:22 AM


All times are GMT +1. The time now is 03:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"