ChangeFileOpenDirectory help

R

Rita King

Hi,
Using Word2002, I have the following script which works OK. My problem is
that I have used the ChangeFileOpenDirectory command.
I would like the users directory to remain at whatever it was before they
run this macro.
So for instance if the user were to press Ctrl-O and the directory was
Y:\MyFiles then I would like them to be able to run the following macro and
for Y:\MyFiles to remain as the default directory when they press Ctrl-O.
What is the command/procedure for that (please)?

Sub proInputText()
Dim strAns As String
strAns = InputBox("Type the number of the" & Chr(13) & _
"paragraph you wish to insert", "Will Retrieval")
If strAns = "" Then
Exit Sub
Else
ChangeFileOpenDirectory "Y:\Masters\WILLS\"
Selection.InsertFile FileName:=strAns, Range:="", ConfirmConversions:= _
True, Link:=False, Attachment:=False
End If
End Sub
 
S

Steve Lang

Hi Rita,

Just capture the existing directory in a string variable before you run your
process and reset it at the end
Sub proInputText()
Dim strAns As String

DIM strOldDir as String
strOldDir = Options.DefaultFilePath(wdDocumentsPath)
strAns = InputBox("Type the number of the" & Chr(13) & _
"paragraph you wish to insert", "Will Retrieval")
If strAns = "" Then
Exit Sub
Else
ChangeFileOpenDirectory "Y:\Masters\WILLS\"
Selection.InsertFile FileName:=strAns, Range:="", ConfirmConversions:= _
True, Link:=False, Attachment:=False
End If

ChangeFileOpenDirectory strOldDir

HTH and have a great day!

Steve Lang
 

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