Solved

msoFileDialogSaveAs options

Posted on 2008-10-16
11
486 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

778 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