0
votes

I use the macro Word letter template to generate customized letters. After I run the macro, the new document is not in focus, and is behind other documents that are opened.

  1. The new document hasn't been saved, so the name of the document is "Document XX"
  2. I tried ActiveDocument.Activate, and the code below. The letter template is a macro userform.
Dim odoc As Document
Set odoc = Documents.Add("\\XXXX\LetterTemplate.dotx", Visible:=True)

How do I bring the active document into view?

2

2 Answers

0
votes

The Active Document is already active.

Try:

oDoc.Activate

It should have become the active document when created and at the front. Do you have other code involving screenupdating?

0
votes

A radical approach is to minimize all open application windows. Then when your code opens a document, it will be the only window displayed.

Sub MinimizeAll()
    Dim shell As Object
    Set shell = CreateObject("shell.application")
    shell.MinimizeAll
    Set shell = Nothing
End Sub

You and your end-users will have to decide if that is an acceptable approach because this can be an annoying solution on two-monitor systems.