Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I open Winword.exe in VBScript?

Status
Not open for further replies.

vtom

Technical User
Apr 8, 2004
3
US
That's my question...and I'm able to get this to work by doing this:

set WshShell = CreateObject ("WScript.Shell")

WshShell.Run "D:\Progra~1\Micros~1\Office\Winword.exe"

However, what if I run this on another machine and the path is not on the D:, but the C:. Instead of changing the path to C:, I'd like the VBS to find winword.exe and launch it.
How do I do this?

Thanks
 
Easiest way is to read the registry via regobj and get the path from the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe
There are two values you might be interested in in that key:

One is the (default) and it has the 8.3 format path and the other is "PATH" and has the long filename format path.

The absence(sp?) of the key means winword is not installed usually(or is not fully installed).

I can write the code if need be. Let me know.

Roger
 
yeah Roger,

That would help a lot. I'm a beginner w/ VBScript and I'm just playing around a bit. I'm not too sure how to enable my vbs to search the registry like you said. As I said above, I:

set WshShell = CreateObject ("WScript.Shell")
 
I got it.
Instead of putting the entire path I just put:

WshShell.Run "Winword"

That seems to work fine.
 
why not forget about the shell and try

Set objWord = Wscript.CreateObject("Word.Application")
appWord.Visible = True


at least that way you do what you want to word afterwardds, ie open specific file, format stuff blaa blaa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top