Solved

Dialogs(xlDialogSaveAs) default location problem

Posted on 2011-03-16
9
1,266 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
Comment Utility
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
Comment Utility
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
Comment Utility
Works fine for me - are you sure you have a real date in the range Date?
0
 

Author Comment

by:antonioking
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 85

Expert Comment

by:Rory Archibald
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
@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
Comment Utility
The GetSaveAsFilename function does the dialog in akoster's code.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now