How can I copy a closed Excel file to a new Excel file??
I just realized that the only problem with the code below is that
all of that VBA code would also be copied into the new file, right??
I'm going to be copying LOTS of closed Excel files to new file
names, and I dont want the new files to have all that VBA code.
You have mentioned "current workbook" and hence "Gary''s Student"'s response
is around copying the current workbook to a new workbook. If you are looking
at copying a closed workbook to a different name try the conventional
FileCopy method
Filecopy "c:\test1.xls","d:\test2.xls"
Or you can try the FileSystemObject CopyFile Method
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists("c:\test1.xls") Then
fso.CopyFile "c:\test1.xls", "d:\destfolder\"
End If
'Get the filename
'Returns False if the user cancels the dialog box.
FileName = Application.GetSaveAsFilename _
(FilterIndex:=5, Title:="Save As")
If FileName = False Then
MsgBox "No file was saved."
Exit Sub
End If
'Display full name and path of file selected
MsgBox "Your file will be saved as " & FileName
End Sub
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.