Solved

msoFileDialogSaveAs options

Posted on 2008-10-16
11
499 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
[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
  • 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
Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

 

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: 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.

Question has a verified solution.

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

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.

630 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