Get location of Word application

  • Thread starter Thread starter Si
  • Start date Start date
S

Si

I use the Shell function to open MS Word (winword.exe) but for some PCs the
install path of Winword.exe is different. Is there any way to get the
directory path of Winword.exe and use that to access the file (rather than
hardcode "C:\Program Files\Microsoft Office\... " etc.)?

Thanks.
 
Why not just shell out to the actual document name?

You can use


application.FollowHyperlink "c:\path name to your docuemnt\test.doc"

Note with the above one line of code, you can launch word, excel, a pdf
file...it really don't matter where, the application is installed, as the
above just launches the file as if you clicked on it...
 
Albert D.Kallal said:
Why not just shell out to the actual document name?

You can use


application.FollowHyperlink "c:\path name to your docuemnt\test.doc"

Note with the above one line of code, you can launch word, excel, a pdf
file...it really don't matter where, the application is installed, as the
above just launches the file as if you clicked on it...

It's an empty/new Word document I want to open. The only way I can see your
suggestion working is if I create a blank Word document and put it as
Read-only on a network resource, so everyone can accesss it. Suppose that
would work OK but it relies on the file being accessible by all.
 
It's an empty/new Word document I want to open. The only way I can see
your suggestion working is if I create a blank Word document and put it as
Read-only on a network resource, so everyone can accesss it. Suppose that
would work OK but it relies on the file being accessible by all.

Ah, ok, we don't really just want to launch word, but want to launch word,
and create a new blank document (different problem, and a different
solution!!).

First, you could just include a blank word document with the application
that
you deploy? (no need to place a blank document on a shared network
resource?). I mention this, since it sounds like you might be deploying your
application wrong. Since you can NOT allow multiple users into the same
front
end of the applications, then one has to assume than EACH user has a copy
of
the front end application installed on EACH pc. Thus, why not include a
blank document on each pc?

In the above case that you might be deploying your application incorrect,
you can
read the following article of mine on how to do this correctly:

http://www.members.shaw.ca/AlbertKallal/Articles/split/index.htm


However, the above is not the issue here (except that you might be
deploying your application Wong), it is MUCH easer to
launch word and THEN TELL word to create a blank document
for.

You can use the following code:

Dim wordApp As Object 'Word.Applicaton
Dim WordDoc As Object 'Word.Document

Set wordApp = CreateObject("Word.Application")

Set WordDoc = wordApp.Documents.Add

wordApp.Visible = True
wordApp.Activate
wordApp.WindowState = 0 'wdWindowStateRestore
 

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

Back
Top