View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Julian Milano[_2_] Julian Milano[_2_] is offline
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