Access-to-Excal Automation - Saving an Excel File

G

Guest

I have this running in Access...

ActiveWorkbook.SaveAs filename:=IPFile, FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

"IPFile" is a string for the File Path.

Running this code for a "first save" of the IPFile
is fine. However, I get an "object not set" if the
File exists.

Solution???

TIA - Bob
 
J

Jim

Listen to anyone else that responds over my comment.

I've not had this issue before but that may be because if a file exists that
is about to be recreated (save, filecopy, etc.) I delete or kill the file
first.
 
G

Guest

Jim...Your comment is Wonderful.

I did this...snippet...
IPFile = "C:\BobDev\" & M & S & ".xls"
bIPFile = True: ChDir "C:\BobDev"
If Dir(IPFile) <> "" Then Kill IPFile
ActiveWorkbook.SaveAs filename:=IPFile, FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

And...it WORKS - THANK you - Bob
 
V

Van T. Dinh

I tend to check for existence of the file first and then use Workbook.Save
if the file exists or Workbook.SaveAs if the file doesn't.

Check Excel VB Help on Save & SaveAs methods of the Workbook object.
 

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