From a macro in Excel, I open a .docm Word doc then search for "<>" (the only text on its line) and replace it with a page break. After the page break is inserted, it leaves an empty line at the end of the previous page where "<>" was. So I'd like to use the SendKeys function to simulate pressing the up arrow key and then backspace to go up to this empty line and then delete it. SendKeys works in the active window, so I'm trying to switch the currently active window (Excel) to the Word doc. But everything I have tried hasn't worked. I can't figure out why VBA won't activate the Word Doc! Please help! Thanks in advance! :)
(Below I labeled what I tried that didn't work)
'EARLY BINDING
Dim WordApp As Word.Application
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
Dim WordDoc As Word.Document
Set WordDoc = WordApp.Documents.Open(Filename:=word_template_path, ReadOnly:=False)
With WordDoc.Application.Selection
.Find.Text = "<<new page>>"
.Find.Execute
.InsertBreak
' AppActivate "Microsoft Word" - didn't work
' Dim wn As Window
' For Each wn In Application.Windows
' Debug.Print wn.Caption
' Next wn
'^ This loop doesn't even show the word file either! It only iterates once, showing the Excel file the macro is saved in!
' WordDoc.Activate - didn't work
' WordApp.Activate - didn't work
' WordDoc.Windows(1).Activate - didn't work
SendKeys "{UP}"
.TypeBackspace
.EndOf
End With


<<new page>>[newline], that way you won't have to do SendKeys. Looks like Word is a bit peculiar on how to do that, this might help superuser.com/questions/124759/…