Answer the question
In order to leave comments, you need to log in
How to use a macro to set focus to the current document?
I can’t transfer the focus to the document from which the macro is launched, that is, it is necessary to force the focus back to the abandoned document, after which the macro will complete its work. Tried different ways, but none of the options worked:
ThisDocument.Activate
ThisDocumnet.SetFocus
Documents(ThisDocument.Name).Activate
Answer the question
In order to leave comments, you need to log in
Sub Activate()
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim wdDocTwo As Word.Document
Set wdApp = CreateObject("word.Application")
wdApp.Visible = True
Set wdDoc = ThisDocument
Set wdDocTwo = wdApp.Documents.Add
wdDocTwo.Activate 'активация окна( но не выводит на передний план)
AppActivate (wdDocTwo.Name)' выведет окно wdDocTwo на передний план
End Sub
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question