From an instance of excel ( file "MasterMacro") I run the below macro that executes a macro in another opened instance of ecxel ( file "VinR" and macro name "SaveFiles")
The SaveFiles macro renames the file - I guess here lyes the problem -
from the "MasterMacro" file
- Code: Select all
Sub VinR_H_SAVEfiles()
'Dim xlApp As Object
'Dim NameOfFile As String
NameOfFile = "C:\Excel files\VinR-H.xlsm"
Set xlApp = GetObject(NameOfFile) ' the file is already opened
xlApp.Application.Run "'VinR-H.xlsm'!SAVEfiles"
xlApp.Close
xlApp.Quit '........ ERROR here ................
Set xlApp = Nothing
End Sub
and the macro "SaveFiles" from the second excel instance
- Code: Select all
ThisWorkbook.Save
saveNAME = ThisWorkbook.Sheets("MyBets").Range("BP5").Value
ThisWorkbook.SaveAs Filename:= _
"C:\Excel files\" & saveNAME & ".xlsm", FileFormat:= _
xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
The error I get is:
Runtime error 2147417848(80010108)
Automation error
The object invoked has disconnected from its client
It may have to do with setting the variables correctly to excel application, workbooks etc ....
Any ideas?