Using the Insert File Dialog

A

Anne Pontillo

Hi,

I am working on a template that needs to insert a file into the new document
created by the template (using Word 2000). When the InsertFile dialog is
called, I need it to point to a specific directory (C:\Columbus Radiology
Emails), with the files of type set to Text files. I have the following
code:

Public Sub InsertAFile()
With Dialogs(wdDialogInsertFile)
.Name = "C:\Columbus Radiology Emails\*.txt"
.Show
End With
End Sub

When I run this code, it opens the InsertFile dialog box with files of type
set to Text files, however, it does not select the correct directory (it
goes to the default directory, My Documents). I can't set the default
document directory to the above, because this path is only used once a week
for this one particular task. The rest of the time, My Documents is used
for opening closing and saving documents.

Thanks in advance for any help.
 
D

Doug Robbins - Word MVP

Hi Anne,

Use:

Dim defpath As String
'Get the present default filepath for documents
defpath = Options.DefaultFilePath(wdDocumentsPath)
'Change it to C:\Columbus Radiology Emails
Options.DefaultFilePath(wdDocumentsPath) = "C:\Columbus Radiology Emails"
With Dialogs(wdDialogInsertFile)
.Name = "*.txt"
.Show
End With
'Change the default filepath for documents back to the original default
Options.DefaultFilePath(wdDocumentsPath) = defpath

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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