View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
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