-
Dave: I am a jerk. I was peeved because I wanted the code. I didn't want to have to work it out. But I came back an hour later, looked again, and (doh) noticed another page, and so on, and so forth. I ended up searching for bookmarks at MrE and was able to find something that DID work.
I thank you soooo much for posting. If you hadn't, I probably would:
a) have waited for someone else to code it
b) given up
Here's the code I ended up using. It's beautiful:
[vba]Option Explicit
Public pappWord As Word.Application
Private Sub Merge()
On Error GoTo ErrorHandler
Dim TodayDate As String
Dim Path As String
Set pappWord = GetObject(, "Word.Application")
TodayDate = Format(Date, "mmmm d, yyyy")
Path = Application.ThisWorkbook.Path & "\pushmerge.dot"
pappWord.Documents.Add Path
On Error Resume Next
With pappWord.Selection
.GoTo What:=wdGoToBookmark, Name:="Ddate"
.TypeText Text:=Range("Ddate")
.Bookmarks.Add Range:=Selection.Range, Name:="Ddate"
.GoTo What:=wdGoToBookmark, Name:="NamePark"
.TypeText Text:=Range("B2")
.Bookmarks.Add Range:=Selection.Range, Name:="NamePark"
.GoTo What:=wdGoToBookmark, Name:="StAdd"
.TypeText Text:=Range("B3")
.Bookmarks.Add Range:=Selection.Range, Name:="StAdd"
.GoTo What:=wdGoToBookmark, Name:="CitySt"
.TypeText Text:=Range("B4")
.Bookmarks.Add Range:=Selection.Range, Name:="CitySt"
End With
On Error GoTo 0
With pappWord
.Selection.WholeStory
.Selection.Fields.Update
.Selection.HomeKey Unit:=wdStory
.ActiveWindow.WindowState = 0
.Visible = True
.Activate
End With
ErrorExit:
Set pappWord = Nothing
Exit Sub
ErrorHandler:
If Err.Number = 429 Then
Set pappWord = CreateObject("Word.Application")
Resume Next
Else
MsgBox "Error No: " & Err.Number & "; Can?t open Word "
Resume ErrorExit
End If
0
End Sub[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules