Using the following code the Word document does not appear on top but rather shows up in the task tray. I have tried inserting DoEvents as well as .Activate and nothing seems to work. Here is the code:
Dim objWD2 As Word.Application
Dim oDoc As Word.Document
Dim oSec As Word.Section
Set objWD2 = CreateObject("Word.Application")
Set oDoc = objWD2.Documents.Open(path)
Set oSec = oDoc.Sections(1)
oSec.Headers(wdHeaderFooterPrimary).Range.Text = oDoc.Name
oSec.Headers(wdHeaderFooterPrimary).PageNumbers.Add.Alignment =
wdAlignPageNumberRight
oSec.Headers(wdHeaderFooterPrimary).PageNumbers.NumberStyle = wdPageNumberStyleNumberInDash
objWD2.ActiveDocument.PageSetup.Orientation = wdOrientLandscape
objWD2.ActiveDocument.Tables(1).AutoFitBehavior (wdAutoFitWindow)
objWD2.ActiveDocument.SaveAs FileName:=path
objWD2.Application.WindowState = wdWindowStateMaximize
objWD2.Visible = True
Any suggestions would be appreciated
Dim objWD2 As Word.Application
Dim oDoc As Word.Document
Dim oSec As Word.Section
Set objWD2 = CreateObject("Word.Application")
Set oDoc = objWD2.Documents.Open(path)
Set oSec = oDoc.Sections(1)
oSec.Headers(wdHeaderFooterPrimary).Range.Text = oDoc.Name
oSec.Headers(wdHeaderFooterPrimary).PageNumbers.Add.Alignment =
wdAlignPageNumberRight
oSec.Headers(wdHeaderFooterPrimary).PageNumbers.NumberStyle = wdPageNumberStyleNumberInDash
objWD2.ActiveDocument.PageSetup.Orientation = wdOrientLandscape
objWD2.ActiveDocument.Tables(1).AutoFitBehavior (wdAutoFitWindow)
objWD2.ActiveDocument.SaveAs FileName:=path
objWD2.Application.WindowState = wdWindowStateMaximize
objWD2.Visible = True
Any suggestions would be appreciated