Changing Directory issue, and Eliminating error messages

  • Thread starter Thread starter John Baker
  • Start date Start date
J

John Baker

Hi:

I am programmatically saving a file, and already have a file by the same name on my disc.
I wish to save WITHOUT GETTING A MESSAGE. I know there is some way I can avoid an error
message, but don't know what it is.

In addition, is there some way I can make a ChDir command stick without saving the file! I
have a situation where I switch directories (to a history file), save the spreadsheet and
then want to reset the directory to the original one. Unfortunately the following does not
work:

(wbpath is the directory for history)

ChDir wbpath
ActiveWorkbook.SaveAs Filename:="Timesheets.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False

ChDir "C:\ipt\timesheet"

It saves the file just fine, but when i later want to execute something which assumes I am
in the timesheet directory, i find that I am still in the history directory.

Help Please

John Baker
 
John

No need to change director when saving a file. I have included path
file name into the save as command

I assumed wbpathj does not end with \



Application.DisplayAlerts = False

ActiveWorkbook.SaveAs FileName:=wbpath & "\Timesheets.xls"
FileFormat:= _
xlNormal, Password:="", WriteResPassword:=""
ReadOnlyRecommended:=False _
, CreateBackup:=False
Application.DisplayAlerts = Tru
 

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

Save as marco 3
Save As File Format 1
Simplify save code 11
SaveAs to existing file 5
saving a file 1
Save copies in different places 4
Save Macro w Suggested File Name to Network Drive 1
Enable/Disable Macro 2

Back
Top