I am adding Word docs to an existing instance of Word via automation from inside a word addin, here is the code that does that:
On Error Resume Next
'Try an establish link to open instnace of Word
Set objWorkpaperWord = GetObject(, "Word.Application")
' if this fails then open a new word app
If objWorkpaperWord Is Nothing Then
Set objWorkpaperWord = CreateObject("Word.Application")
objWorkpaperWord.Visible = True
objWorkpaperWord.Documents.Add (arrFilePaths(iSelectedTitle) & "" & WorkpaperTemplates(iSelectedTitle, iSelectedCategories, iSelectedWorkPaper))
objWorkpaperWord.ActiveWindow.Caption = strDocname
Set objWorkpaperWord = Nothing
And this is sucessfully adding the word doc to the existing instance but there is a problem in that the new added document is not active. The icon on the status bar for the new document is active and the document the caption is correct but the area that contains the caption is grayed out and I first have to select the document before it becomes active. How do I do this via VBA code?
I have tried adding code in the template that is being added in it's ThisDocument_New event such as :
' Make sure this document has the focus
But this does help.