Opening WORD from Excel

B

Bob Reynolds

Hello, I am using the following code to open and WORD document on my
computer. However I need to send it to a bunch of people and although the
files will be place in a central location, the path that I'm using isn't
accurate for their machines.

How can I change the code to look for each individual document (named the
same as on my computer) and update the path?

Private Sub CommandButton1_Click()
Dim wd As Object
Set wd = CreateObject("Word.Application")
wd.Visible = True
wd.Documents.Open ("C:\Documents and Settings\BOB
REYNOLDS\Desktop\Forms-Letters-COJ\Letters & Merge Data\L01 Appointment
Letter 06282004.doc")
End Sub

The new folder will be on the desktop, but someone else's name.
Thanks so much
Bob Reynolds
 
S

Steve Yandl

Bob,

Something like

Set objShell = CreateObject("Shell.Application")
Set objFolderMyDesk = objShell.Namespace(&H10&)
strMyDeskPath = objFolderMyDesk.Self.Path

will return "strMyDeskPath" as the path string to the individual user's
desktop. If building a path statement, don't forget to include the
backslash &"\"& with the subfolder and file name after.

Steve
 

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