Save as marco

J

John

I am trying to create a macro that will first save the file and then second
save as to a new location and new file name.

Here is what I have and it doesn't work after the first save.

Sub autosave()
ActiveWorkbook.Save
ChDir "R:\"
ActiveWorkbook.SaveAs Filename:="R:\Service.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub

I tried it with and without the ChDir "R:\" and that did not work either.

I also tried just

ActiveWorkbook.SaveAs Filename:="R:\Service.xls"

and that also did not work.

Thank you for any and all help.
 
J

Jacob Skaria

Try changing your path to c:\temp ...and if that is working. check the folder
rights in R:\

Sub autosave()
Dim strFileName as String
strFileName = "R:\service.xls"
ActiveWorkbook.Save
ActiveWorkbook.SaveAs Filename:=strFileName
End Sub
 
J

John

I changed the path to "C:\temp\servive.xls" and it still did not work.

I keep getting the code exexution has been interrupted box
 
J

Jacob Skaria

You must be trying with a read-only file. Ignore save and go with Save As

'ActiveWorkbook.Save
ActiveWorkbook.SaveAs Filename:=strFileName
 

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

Similar Threads

Simplify save code 11
Save As File Format 1
SaveAs to existing file 5
Save with ref. to cell A1 2
Enable/Disable Macro 2
Hiding an Excel file using VBA 1
saving a file 1
Saving a workbook to an iKnow portal 2

Top