Results 1 to 2 of 2
2006-06-02, 15:26 #1
- Join Date
- Mar 2003
- Elkins Park, Pennsylvania, USA
- Thanked 0 Times in 0 Posts
VBA Problem with FileSaveAs dialog in VBA (Word XP/VBA)
OK, this is truly bizarre.
I have some code that, among other things, saves a copy of each file that a user might have open (so that the original files aren't altered.) For each document, I currently throw up the FileDialog "msoFileDialogSaveAs." However, I noticed a serious problem when the code runs on a machine where Word has been configured to "Show Windows on Taskbar".
On machines where that option is turned OFF, everything works fine. My code activates the proper documents, throws up a somewhat-customized "Save As..." dialog box for each one, and returns the name and the correct document-object for the file that was just saved. But when a user has the option turned ON, then it doesn't seem to matter which document is activate when the Save As dialog is called; Word seems to totally ignore it. When I step through the code, I can literally see the active document change to a different document as soon as the ".show" method is called. It seems almost that Word will pick any open document at random (or maybe it keeps re-activating the first one that the user used with the Save As...? I don't know for sure)
In trouble-shooting this, I have reset the FileDialog variable to "nothing" in between each call, but that has no positive effect. I make sure that the document I want to "Save As" is activated in the line IMMEDIATELY PRECEEDING the line with .Show... I'm at wit's end! Currently, the only workaround I can possible imagine is to get the user's current WindowsInTaskbar setting, store it, turn it off, and then restore the original setting at the end of the code. (The only problem with this is that I'm not a big fan of changing a user's configuration, even though I personally think that particular option is one of the most confounding and useless options introduced in XP.)
Someone, please show me the way!!!<font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike
2006-06-02, 22:39 #2
- Join Date
- Mar 2002
- Thanked 30 Times in 30 Posts
Re: VBA Problem with FileSaveAs dialog in VBA (Word XP/VBA)
Try using Application.Dialogs(wdDialogFileSaveAs) instead of Application.FileDialog(msoFileDialogSaveAs). The Display method of the dialog object displays the dialog but doesn't execute its action (leaving it up to the programmer to do something if desired), the Show method actually executes the action of the dialog if the user clicks Save.