I have a code that opens a word document and inserts values.
The code first checks to see if word is open and then either uses it or opens it.
If it opens it, it pops up as the front window, but if word is already open, it creates a document without bringing the window to the front.
What bit of code needs to be added to make an existing background version of word become the open and active window?
On Error Resume Next
Set objWord = GetObject(, “Word.Application”)
If Err.Number = 429 Then
‘Word is not running; creating a Word object
Set objWord = CreateObject(“Word.Application”)
Err.Clear
End If
———-
get values for fields here
———-
objWord.Selection.WholeStory
objWord.Selection.Fields.Update
objWord.Selection.HomeKey Unit:=6
objWord.Visible = True
objWord.Activate