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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Word and Make Active 1

Status
Not open for further replies.

sweevo

Programmer
Jan 30, 2002
182
GB
Hello,

I have a script which opens a file in Word:
Code:
Sub openWord(sFilename)
  Set oWord = CreateObject("Word.Application")
  oWord.Visible = True
  oWord.Documents.Open(sFileName)
  Set oWord = nothing
End Sub
Currently this creates a Word instance behind any existing applications. What I need to know is, how can I make this the active/foremost window from the script?

Thanks.

 
Have a look at the WshShell.AppActivate method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks,

Works well.

Here's what I have now...
Code:
Sub openWord(sFilename)
  Set oShell = CreateObject("wscript.shell")
  Set oWord = CreateObject("Word.Application")
  oWord.Visible = True
  oWord.Documents.Open(sFileName)
  oShell.AppActivate "Microsoft Word"
  Set oWord = nothing
  Set oShell = nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top