Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

msoFileDialogSaveAs options

Posted on 2008-10-16
11
Medium Priority
?
508 Views
Last Modified: 2012-05-05
Looking to combine two things.  First, I have code to determine the "CurrentFolder" that the ActiveDocument is from.  Second, I know how to call the msoFileDialogSaveAs dialog and create have an InitialFileName placed in the Save As field.  However, I want the folder to be the Current Folder, not the MyDocuments folder.  That is, I want the automated setting to be when the Save As dialog appears to be twofold: first a "recommended" file name (InitialFileName), and a "recommend" folder location (Current Folder), so that the user has essential the option of just selecting save with no further manipulation of the Save As dialog.
0
Comment
Question by:HardyDesertDuo
  • 6
  • 5
11 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 22736046
An open document has a Path property, so
strCurrentFolder = ActiveDocument.Path would give you that.

I usually use the Word SaveAs dialogue. This has a Name property:

    Dim dlg As Dialog
    Set dlg = Dialogs(wdDialogFileSaveAs)
    dlg.Name = ActiveDocument.FullName
    dlg.Show
0
 

Author Comment

by:HardyDesertDuo
ID: 22737113
Doesn't work.  I guess I want to change the "default" folder to be the folder of the ActiveDocument.Path so that when I select "Save As" on the command bar, the dialog is down the directory tree to the ActiveDocument.Path
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 22738474
It works with the Word dialogue. I tested it again before posting.

I recall that Chdir (change default directory) also works if the path is not supplied in the Name string.
Note that new documents (Document1, etc) will not have a path om th FullName property.

If you are using the Office dialogue, can you post your code, please?
0
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 

Author Comment

by:HardyDesertDuo
ID: 22739107
Okay.  Sorry for the confusion.  I'm working with a new document (Document1, etc) from a template.  I'm trying to "force" the Save As dialog to "open" to the same folder as the document template from which the Document1 was "created."  I've been fooling around with iterations of Chdir and ActiveDocument.AttachedTempate.Path which "works' inasmuchas I can created a string of the path I want Document1 to go in, but I cannot seems to get that path associated with the Save As dialog the first time I try to save Document1.  I also want to "suggest" a name for Document1 in the Save As dialog.  So, the sequence of events is as follows: Start a new document from a Template, information is entered into a userform that opens when a new document is started, upon selecting the command button "Create Document" on the userform, the FormFields in the document are populated based on userform entry.  Now, when the user selects "Save As" (in Word command bar), I want the the Save As dialog to default to the directory from which the original template came and "suggest" the name of the file to be a string based on userform information, not Document1 (I know how to create that string...just don't know how to make it the Name for Save As dialog).  Would ChangeFileOpenDirectory help?  OBTW: I'll use Word dialog, not a problem there.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 22739142
Does this help?
Sub MyFileSaveAs()
    Dim dlg As Dialog
    Set dlg = Dialogs(wdDialogFileSaveAs)
    dlg.Name = ActiveDocument.AttachedTemplate.path & "\" & "SuggestedName.doc"
    dlg.Show
End Sub

Open in new window

0
 

Author Comment

by:HardyDesertDuo
ID: 22739339
How do I associate (call) the MyFileSaveAs procedure with the "Save As" command on the Command Tool Bar?
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 22739405
Use Tools/Customize to en the Customize window.

If necessary, you can create a new toolbar with the Toolbars tab. You can also make sure that the target toolbar is visible here.

On the Commands tab, select Macros in Categories, then find your macro in the right-hand box and drag it to the toolbar of your choice. While it is selected, now or later, you can edit it by using the Modify Selection button.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 22739412
Oops. "en" should be "open"
0
 

Author Closing Comment

by:HardyDesertDuo
ID: 31506916
I successfully created a new toolbar command button called "Save Document" that is associated with the MyFileSaveAs macro.  That's probably what I'm gonna have to go with and not use the built-in Save As command.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 22739819
I didn't take on board the fact that you wanted to intercept the FileSaveAs command.

A macro with the same name as a Word command will run in preference to the Command itself, so you simply need to change the macro name to FileSaveAs. It will then run if the user tries to save to use File/SaveAs menu item.
0
 

Author Comment

by:HardyDesertDuo
ID: 22739834
Awesome!  Sorry for the confusion.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …
Suggested Courses

886 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