filename variable not working in Word2000

R

Roger Marrs

I also posted this question on the vba.beginners list, but thought maybe
this list might be more appropriate.
For some reason when using Word2000 the code I'm using to
insert a file name into the SaveAs dialog box causes problems.

The following code works to open the SaveAs dialog box ready to save a
document in a specific folder:
With Dialogs(wdDialogFileSaveAs)
.Name = "\\Server\FullCase\CaseDocs\" & CaseNumber & "\"
.Show
End With

Using that code the correct folder is opened and the only thing the user
needs to do is enter a filename for the document.

What I really want to happen is for the macro to pre-fill the filename
section of the SaveAs dialog box. In Word2003 I'm able to make this happen
using the following code. However, in Word2000 the dialog box opens to the
last folder used by Word to save a document, rather than using the folder
path designated by the macro. Here's the code I'm using that works in
Word2003 but not Word 2000:
With Dialogs(wdDialogFileSaveAs)
.Name = "\\Server\FullCase\CaseDocs\" & CaseNumber & "\" & DocFileName
.Show
End With

As you can see, the only difference between the two versions of code is the
addition of the variable "& DocFileName." The variable is handled earlier
in the macro code with a Dim as String statement and the variable
DocFileName obtains it's value from a bookmark in the ActiveDocument.

Does anyone know why adding the variable & DocFileName screws up this
otherwise handy bit of code in Word2000, but not Word2003?

Roger
 
C

Cindy Meister

<<Does anyone know why adding the variable & DocFileName screws up this
otherwise handy bit of code in Word2000, but not Word2003?>>

Because Word 2000 was buggier than Word 2003; simple answer, but true...

You might try using SendKeys with the path + [Enter], just before calling
the dialog box. And then put only the file name into the .Name property.

You might also see whether .Display behaves any differently than .Show (it
does, in some cases, in some versions).
 
R

Roger Marrs

Thanks Cindy. I'll see if I can figure out how to use the SendKeys code.

Roger

Cindy Meister said:
<<Does anyone know why adding the variable & DocFileName screws up this
otherwise handy bit of code in Word2000, but not Word2003?>>

Because Word 2000 was buggier than Word 2003; simple answer, but true...

You might try using SendKeys with the path + [Enter], just before calling
the dialog box. And then put only the file name into the .Name property.

You might also see whether .Display behaves any differently than .Show (it
does, in some cases, in some versions).
--
-- Cindy


Roger Marrs said:
I also posted this question on the vba.beginners list, but thought maybe
this list might be more appropriate.
For some reason when using Word2000 the code I'm using to
insert a file name into the SaveAs dialog box causes problems.

The following code works to open the SaveAs dialog box ready to save a
document in a specific folder:
With Dialogs(wdDialogFileSaveAs)
.Name = "\\Server\FullCase\CaseDocs\" & CaseNumber & "\"
.Show
End With

Using that code the correct folder is opened and the only thing the user
needs to do is enter a filename for the document.

What I really want to happen is for the macro to pre-fill the filename
section of the SaveAs dialog box. In Word2003 I'm able to make this happen
using the following code. However, in Word2000 the dialog box opens to the
last folder used by Word to save a document, rather than using the folder
path designated by the macro. Here's the code I'm using that works in
Word2003 but not Word 2000:
With Dialogs(wdDialogFileSaveAs)
.Name = "\\Server\FullCase\CaseDocs\" & CaseNumber & "\" & DocFileName
.Show
End With

As you can see, the only difference between the two versions of code is the
addition of the variable "& DocFileName." The variable is handled earlier
in the macro code with a Dim as String statement and the variable
DocFileName obtains it's value from a bookmark in the ActiveDocument.

Does anyone know why adding the variable & DocFileName screws up this
otherwise handy bit of code in Word2000, but not Word2003?

Roger
 

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