run macro from anoter Excel session
Sub test2()
Dim PathToFile As String, NameOfFile As String
Dim XLother As Application
PathToFile = "C:\Temp"
NameOfFile = "myFile.xls"
On Error Resume Next
Set XLother = GetObject(PathToFile & "\" & NameOfFile).Parent
On Error GoTo 0
If XLother Is Nothing Then
MsgBox NameOfFile & " not found"
Else
XLother.Run "myMacro"
End If
End Sub
Regards,
Peter T
"Dan" wrote in message
...
Hi,
I am trying to run a macro from another open workbook on another excel
session.
I have tried using
Application.Run (PathToFile & "\" & NameOfFile & "!MacroName")
but the it open a new workbook (read only) and also get stuck.
Any idea,
Thanks
Dan
|