Solved

Dialogs(xlDialogSaveAs) default location problem

Posted on 2011-03-16
9
1,440 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 450 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 50 total points
ID: 35150507
The GetSaveAsFilename function does the dialog in akoster's code.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

688 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