Closing an inactive workbook

  • Thread starter Thread starter Michael Wise
  • Start date Start date
M

Michael Wise

I have 2 files. One is initially run to save some
changes. Upon the click it saves these changes to a file
called WoNumbers.csv and then proceeds to open the next
file and auto run its macro's. The problem i'm having is
how to close the initial save as file created. Because at
the end of the second file run its procedure is to kill
this WoNumbers.csv created but its still open. I have
pasted the code below for the initial file.

Michael

Private Sub CommandButton1_Click()
ActiveWorkbook.SaveAs Filename:="C:\Psv
travelog\WoNumbers.csv", FileFormat:=xlCSV
'
'
Workbooks.Open ("C:\PSV travelog\PSV WO and
Specs.xls"), ReadOnly:=True
Workbooks("WoNumbers.csv").Close
ActiveWorkbook.RunAutoMacros xlAutoOpen

End Sub
 
Thanks Tom,

Yes it does close the file but my code in the second file will not aut
run. If I move the auto open statment before close then this workboo
is no longer active. I need for the code to auto run when opened in th
second file
 
Private Sub CommandButton1_Click()
Dim wkbk as Workbook
ActiveWorkbook.SaveAs Filename:="C:\Psv
travelog\WoNumbers.csv", FileFormat:=xlCSV
'
'
Set wkbk = Workbooks.Open ( _
"C:\PSV travelog\PSV WO and Specs.xls"), ReadOnly:=True
Workbooks("WoNumbers.csv").Close
wkbk.RunAutoMacros xlAutoOpen

End Sub
 
Back
Top