Problem setting directory in xlDialogSaveAs

J

Jonathan Crow

I am trying to set the directory to a default location
with the xlDialogSaveAs command but can't seem to get it
to work.

Here is my code:
MyDate = Replace(FormatDateTime(Now, vbShortDate), "/", "-
")
MyPath = "C:\Document and Settings\Administrator\My
Documents\Spreadsheets"
Application.Dialogs(xlDialogSaveAs).Show (MyPath
& "\NewSpreadsheet" & MyDate & ".xls")


I have tried changing the directory and setting the
lpstrInitialDir neither of which have worked. The save as
dialog box keeps reverting to my desktop.

Thanks,
Jonathan
 
T

Tom Ogilvy

MyDate = _
Replace(FormatDateTime(Now, vbShortDate), "/", "-")
MyPath = _
"C:\Document and Settings\Administrator\My Documents\Spreadsheets"
Chdrive MyPath
ChDir MyPath
Application.Dialogs(xlDialogSaveAs).Show _
(MyPath & "\NewSpreadsheet" & MyDate & ".xls")

Should work.
 

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