Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Brendan Brendan is offline
external usenet poster
 
Posts: 15
Default Marking up data in Access to import in Word mail merge

Hi Peter,

Thank you so much for your help!

Your script worked very well. Unfortunately my master document was full of
section breaks for formatting and I haven't found a way to fully adapt it, so
we'll still be doing some extra work. But again, thank you for your help.
Much appreciated.

Brendan

"Peter Jamieson" wrote:

Do you know of a way to have it run automatically for each
merged document? Right now I'm having to run it manually (which is still a
step forward, at least).


I would probably create a macro that perforrmed the merge /then/ did the
find/replace. e.g.

Sub MergeThenReplace()
Dim objMMMD As Word.Document 'Mail Merge Main Document

' After the merge, the new document becomes the active document
' So make a reference to the activeDocument in case we
' need to refer to it post-merge (although in this case, we don't)

Set objMMMD = ActiveDocument

With objMMMD.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With

With ActiveDocument.Content.Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Style = ActiveDocument.Styles("Heading 3")
.Replacement.ParagraphFormat.Borders.Shadow = False
.Text = "\h3\(*)\/h3\"
.Replacement.Text = "\1"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With

Set objMMMD = Nothing

End Sub

Peter Jamieson


"Brendan" wrote in message
...
Hi Peter,

Thanks again. You've been a great help.

I recorded the following macro and tested running it on merged documents.
It
works nicely. Do you know of a way to have it run automatically for each
merged document? Right now I'm having to run it manually (which is still a
step forward, at least).

Sub StyleReplace()
'
' StyleReplace Macro
' Macro recorded 5/3/2007 by Brendan
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles("Heading 3")
Selection.Find.Replacement.ParagraphFormat.Borders .Shadow = False
With Selection.Find
.Text = "\h3\(*)\/h3\"
.Replacement.Text = "\1"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub




 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Mail Merge to import Excel data to Word for printing checks [email protected] Mailmerge 2 November 3rd 06 05:10 AM
How do I import access data into a word mail merge document that Rayomand Mailmerge 1 November 29th 05 09:46 PM
capitalization in word of access data via mail merge harvey Mailmerge 1 September 11th 05 10:04 PM
How can I fix the Access data source of the mail merge for Word LCC Mailmerge 0 August 29th 05 03:52 PM
import data into word from excel or access Tlar Microsoft Word Help 0 December 12th 04 10:07 PM


All times are GMT +1. The time now is 11:55 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"