I've got a need to open some excel files and "pause" then close them. In this process I run one macro on opening, and another on closing. The opening one works fine because it is done as each file is opened. But the closing part of the code I can't get it to run the correct macro. They have the same names, but the file contests are different, and what the macro does per file is different.

This is the jist of what I'm doing now:

This first part works fine.

Code:
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True


path = "\\Gaalpa1cdfile19\north_sa_staff\Reports\Rpt-ProductionCurves\"
'------------------------------- 
filename2018P1 = "2018 P1.xlsm"
set xlbook2018P1 = xlApp.WorkBooks.Open( path & filename2018P1)
' Run Macro
xlApp.Run "AutoRefresh"

'-------------------------------
filename2018P3 = "P3 2018 HRR.xlsm"
set xlbook2018P3 = xlApp.WorkBooks.Open( path & filename2018P3)
' Run Macro
xlApp.Run "AutoRefresh"

' My "pause"
wscript.echo ("All Files were" & chr(013) & _
              "opened and refreshed, update ppt before OK" & chr(013) & _
		" DO NOT CLICK OK" & chr(013))
' And the trouble spot. Trying to run the file's respective "Autopublish" macro, then close the file. (The real file names have spaces and I had to add the single quotes to get it to accept the filename.) What it appears to be doing is using the macros from the last file opened, not the one it's directed to use it the run line. I think I need a way to "select" the correct file, or give it focus so the macro could run without an explicit filename argument, which it appears to be ignoring anyway.

Code:
xlapp.run "'" & filename2018P1 & "'" & "!AutoPublish"
xlbook2018P1.Close false
Set xlbook2018P1 = Nothing

xlapp.run "'" & filename2018P3 & "'" & "!AutoPublish"
xlbook2018P3.Close false
Set xlbook2018P3 = Nothing