DavetheVBNewb
New member
- Local time
- Yesterday, 18:26
- Joined
- Jul 1, 2008
- Messages
- 6
Hey Everyone,
I currently have a macro that runs a mail merge from a Access database to a word template. After merging, the new document has section breaks between each record set. A simple find/replace in word will replace these with page breaks, but I'm having trouble making this work from Access. Here's my code:
---
templatePath = "path.doc"
sourceQuery = "Query"
wordDoc.Visible = True
wordDoc.Documents.Open templatePath
[Code for merge]
With wordDoc.Selection.Find
.Text = "^b"
.Replacement.Text = "^m"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
wordDoc.Selection.Find.Execute Replace:=wdReplaceAll
Exit Sub
---
There aren't any errors and when the code finishes the section breaks are highlighted but unchanged. Any Ideas?
Thanks,
Dave
I currently have a macro that runs a mail merge from a Access database to a word template. After merging, the new document has section breaks between each record set. A simple find/replace in word will replace these with page breaks, but I'm having trouble making this work from Access. Here's my code:
---
templatePath = "path.doc"
sourceQuery = "Query"
wordDoc.Visible = True
wordDoc.Documents.Open templatePath
[Code for merge]
With wordDoc.Selection.Find
.Text = "^b"
.Replacement.Text = "^m"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
wordDoc.Selection.Find.Execute Replace:=wdReplaceAll
Exit Sub
---
There aren't any errors and when the code finishes the section breaks are highlighted but unchanged. Any Ideas?
Thanks,
Dave