Excel file

S

skchow

Dear Sir,
I've created macro in Excel file named "macro.xls". This macro is open
Excel file name "pc.xls" from my P.C path "C:\excel\". Once I run the
macro, the Excel file "pc.xls" workbook is open but I want to close the
Excel file("macro.xls") and the Excel file "pc.xls" is remain open for
editing.

The coding as below:
Private Sub Workbook_Open()
filepathw = "c:\excel\"
fileorg = filepathw & "pc.xls"
Workbooks.Open (fileorg)
End Sub
 
D

Dave Peterson

Add

thisworkbook.close savechanges:=false

right before the "End Sub"

It'll close the workbook that containst the procedure. (And it'll close it
without saving. Make sure you save it before you run it.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top