Opening directory

B

Bernd Kuegle

Hi!

I would like to use a vba routine of my Excel where I can open a certain
directory ("G:\DATES\") to select a file but this doesn´t work in Word:

ChDrive "G:\"
ChDir "G:\DATES\"
o_dir = Application.GetOpenFilename("Winword.exe (*.*), *.*")
Workbooks.Open FileName:=o_dir

Thanks
Bernd
 
R

Rick Gutzmer

Change this line:
Workbooks.Open FileName:=o_dir
to this:
Documents.Open FileName:=o_dir
 
R

Rick Gutzmer

sorry - jumped the gun. Try this:

Dim o_dir As String
o_dir = Options.DefaultFilePath(Path:=wdDocumentsPath)
Options.DefaultFilePath(Path:=wdDocumentsPath) = "D:\syxta\templates"
With Application.Dialogs(wdDialogFileOpen)
.Name = "*.doc; *.rtf"
.Show
End With
Options.DefaultFilePath(Path:=wdDocumentsPath) = o_dir
Templates("normal.dot").Saved = True 'so you don't get prompted to save
the normal template on exit
 

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