Solved

msoFileDialogSaveAs options

Posted on 2008-10-16
11
488 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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 125 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

821 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