Solved

Dialogs(xlDialogSaveAs) default location problem

Posted on 2011-03-16
9
1,394 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
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
Industry Leaders: 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:
akoster 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need take combination of numbers out of the list 6 16
any combination of this numbers 9 33
Checking references in VBA 3 25
Tricky Shapes formula part 4 4 15
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

730 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