wdDialogFileSaveAs works in Word 2003 but not Word 2000?

R

Roger Marrs

The following code was developed for use with Word 2003 and it works fine.
However, I've run into a situation where the code seems like it fails to
execute on a Word 2000 machine. Here's the code:

Dim FSO As FileSystemObject
Dim NewDir As String

Set FSO = CreateObject("Scripting.FileSystemObject")

NewDir = "\\Server\FullCase\CaseDocs\" & CaseNumber

If Not FSO.FolderExists(NewDir) Then
FSO.CreateFolder NewDir
End If

With Dialogs(wdDialogFileSaveAs)
.Name = "\\Server\FullCase\CaseDocs\" & CaseNumber & "\" & DocFileName
.Show
End With


What's supposed to happen: Step 1 - The code is supposed to check for the
existence of a specific file folder and to create the folder if it doesn't
exist. Step 2 - Then the Word SaveAs dialog box is supposed to be presented
to the user, with the file path defaulted to the folder that either already
existed or was just created by Step 1.

What actually happens in Word 2000: The Word SaveAs dialog opens with the
file path apparently set to the last place used by Word to save a document.

So my questions are: 1) Is the use of Word 2000 the reason this code isn't
working? 2) If so, can the same task be accomplished in Word 2000? 3) If
so, can someone help me modify the code so it works correctly in Word 2000?
4) And finally, if the version of Word in use is not the culprit here, what
else could be causing the problem?
 
D

Doug Robbins - Word MVP

I believe that the answer to your first question is yes.

The way we used to handle checking for the existing of a folder and creating
it if it did not exist was the trap the error that occurred (I believe that
it was 76) when the ChDir command was used to try and change to the folder
and then using MkDir if the folder did not exist.

I don't have the routine handy at the moment, but may be able to find it if
you really get stuck Check out the VBA help on those commands.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
R

Roger Marrs

After double checking the results of running the code, it appears that the
code to check for the existence of the folder and create it if it doesn't
exist does in fact work on the Word 2000 machine.

So the problem seems to be limited to the wdDialogFileSaveAs portion. This
bit of code should present to the user the Word SaveAs dialog box with the
file ready to be saved to the path establish by .Name:
With Dialogs(wdDialogFileSaveAs)
.Name = "\\Server\FullCase\CaseDocs\" & CaseNumber & "\" & DocFileName
.Show
End With

Instead, the dialog box opens with the path set to whatever folder was last
used by Word to save a file. Is this a problem with Word 2000? Should I be
using some other command to get the path set correctly by the macro?

Roger
 
J

jim

Roger -

I use a variation of the same macro in my lawoffice to save documents
generated both in Word2000 and Word2003. I select some text from the
document that corresponds to a directory name and add that to the file
path so that the document gets saved in the correct directory. Works
every time on both Word2000 and Word2003.

The only difference I see is that I use a mapped network drive rather
than using the UNC path.

Sub SaveMe()
' Macro created 05/05/2003
infoinfo = Selection
With Dialogs(wdDialogFileSaveAs)
.Name = "f:\cases\" & infoinfo & "\" & "name"
.Show
End With

End Sub

Perhaps the dialog chokes if you use the UNC path.

Hope this helps

jim esq.
 
R

Roger Marrs

Thanks Jim,
I thought it might be the UNC, but when the code was tested out using a path
of "C:\CaseDocs\" the result was the same. Which lead me to wonder if the
problem was with the version of Word in use. Since the code you suggested
works for you in both Word2000 and Word2003, I'm really baffled at what
could be causing the probelm.
 
R

Roger Marrs

Is there another way to skin this cat? Can I get to the same end result
without using:
With Dialogs(wdDialogFileSaveAs)
.Name = "\\Server\FullCase\CaseDocs\" & CaseNumber & "\" & DocFileName
.Show
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top