?
Solved

Dialogs(xlDialogSaveAs) default location problem

Posted on 2011-03-16
9
Medium Priority
?
1,496 Views
Last Modified: 2012-05-11
Can someone explain to me why the code below does not open the save as dialog box in the C:\Windows directory?

Kind regards,
Antonio King
strFileLocation = "C:\Windows\"
        strFileName = Format(wsSummary.Range("Date"), "mmm yyyy") & " - Report.xls"
        Application.Dialogs(xlDialogSaveAs).Show strFileLocation & strFileName

Open in new window

0
Comment
Question by:antonioking
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 33

Expert Comment

by:jppinto
ID: 35148506
The problem seem to be here:

strFileName = Format(wsSummary.Range("Date"), "mmm yyyy") & " - Report.xls"

If you try with something like this:

strFileName = "MAR 2011 - Report.xls"

The Save as dialog appears.

jppinto
0
 

Author Comment

by:antonioking
ID: 35148526
Hmm... that wasn't my question but thanks for your input!

there is nothing wrong with strFileName.
The problem is the save as dialog keeps defaulting to the desktop and not to the folder specified in strFileLocation.
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 35148594
Works fine for me - are you sure you have a real date in the range Date?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:antonioking
ID: 35148658
There is nothing wrong with the file name.
The file is correctly named as I want it
That part of the code works perfect.

The problem is the save as dialog defaults to the desktop, and not C:\Windows\
as specified in strFileLocation.

Even if I change the code to the following... the save as dialog STILL defaults to the desktop folder...

strFileLocation = "C:\Windows\"
strFileName = "Report.xls"
Application.Dialogs(xlDialogSaveAs).Show strFileLocation & strFileName

Open in new window

0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 35148690
Which version of Excel are you running this in? (I assume your Windows folder is actually located at "C:\Windows")
0
 
LVL 19

Accepted Solution

by:
Arno Koster earned 1800 total points
ID: 35148713
you can use

ActiveWorkbook.SaveAs Filename:=Application.GetSaveAsFilename(InitialFileName:=strFileLocation & strFileName)

Open in new window


instead of

Application.Dialogs(xlDialogSaveAs).Show strFileLocation & strFileName

Open in new window

0
 

Author Comment

by:antonioking
ID: 35148727
Yep Windows folder is located in C:\Windows
I've even tried creating folders on the C Drive and changing the strFileLocation to that location.... still no joy. It keeps defaulting to the desktop!
Using Excel 2003 on Windows 7 Pro

Regards
0
 

Author Comment

by:antonioking
ID: 35150311
@akoster
The activeworkbook.saveas method does not present the user with a dialog box.
The save as dialog window must pop up to give the user the option of where to save the file.
0
 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 200 total points
ID: 35150507
The GetSaveAsFilename function does the dialog in akoster's code.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question