Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Marking up data in Access to import in Word mail merge
I have a field in my database that stores an outline of topics covered in a
course. The data is made up of headings and text. In my Word document I've created a new style called "heading3". Is there anyway to mark up the entries in the database field so that Word will know to apply "heading3" to the headings? |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Marking up data in Access to import in Word mail merge
Not really, if you mean that you want to be able to store /any/ style name
with the data. If you want to do that, you would probably have to use VBA and Word's Mailmerge Events to apply the style specified in your data. You could probably apply a limited number of predefined styles using an INCLUDETEXT, e.g. you put the following in a file called c:\include\myfield.doc: bookmark the following line as "style1" and apply style "style1" to it: { MERGEFIELD myfield } bookmark the following line as "style2" and apply style "style2" to it: { MERGEFIELD myfield } bookmark the following line as "style3" and apply style "style3" to it: { MERGEFIELD myfield } and so on... then in your mail merge main document, use { INCLUDETEXT "c:\\include\\myfield.doc" "{ MERGEFIELD mystyle }" } However, I haven't checked and you may find that the style in the main document is used anyway. Peter Jamieson "Brendan" wrote in message ... I have a field in my database that stores an outline of topics covered in a course. The data is made up of headings and text. In my Word document I've created a new style called "heading3". Is there anyway to mark up the entries in the database field so that Word will know to apply "heading3" to the headings? |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Marking up data in Access to import in Word mail merge
I think I understand where this is going, but I'm not clear on how I would
need to mark-up the content of the database field to indicate where a header begins and ends. Can you provide further insight? Thanks. Brendan "Peter Jamieson" wrote: Not really, if you mean that you want to be able to store /any/ style name with the data. If you want to do that, you would probably have to use VBA and Word's Mailmerge Events to apply the style specified in your data. You could probably apply a limited number of predefined styles using an INCLUDETEXT, e.g. you put the following in a file called c:\include\myfield.doc: bookmark the following line as "style1" and apply style "style1" to it: { MERGEFIELD myfield } bookmark the following line as "style2" and apply style "style2" to it: { MERGEFIELD myfield } bookmark the following line as "style3" and apply style "style3" to it: { MERGEFIELD myfield } and so on... then in your mail merge main document, use { INCLUDETEXT "c:\\include\\myfield.doc" "{ MERGEFIELD mystyle }" } However, I haven't checked and you may find that the style in the main document is used anyway. Peter Jamieson "Brendan" wrote in message ... I have a field in my database that stores an outline of topics covered in a course. The data is made up of headings and text. In my Word document I've created a new style called "heading3". Is there anyway to mark up the entries in the database field so that Word will know to apply "heading3" to the headings? |
#4
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Marking up data in Access to import in Word mail merge
OK, I re-read your message and I don't think what I suggested is going to be
enough. If you need to mark up parts of your text field, the task becomes much harder. Either you would have to write VBA and use Word events to look for markup in your text field and apply the appropriate formatting, or you would probably have to markup your text in a way that allowed you to export the content of your field to files (one for each record in your data source) that you then included either with code or with an INCLUDETEXT. In that case the markup would have to be in a format that Word already understood. It might be HTML markup (but I don't know off the top of my head whether you would be able to mark up using paragraph or character style names that Word would recognise and apply) or RTF markup (even if that could be made to work, it would render your field substantially less readable even than using HTML markup). Out of those three choices I think I'd probably opt for the "VBA and merge events" one, if I really had to do it at all. Peter Jamieson "Brendan" wrote in message news I think I understand where this is going, but I'm not clear on how I would need to mark-up the content of the database field to indicate where a header begins and ends. Can you provide further insight? Thanks. Brendan "Peter Jamieson" wrote: Not really, if you mean that you want to be able to store /any/ style name with the data. If you want to do that, you would probably have to use VBA and Word's Mailmerge Events to apply the style specified in your data. You could probably apply a limited number of predefined styles using an INCLUDETEXT, e.g. you put the following in a file called c:\include\myfield.doc: bookmark the following line as "style1" and apply style "style1" to it: { MERGEFIELD myfield } bookmark the following line as "style2" and apply style "style2" to it: { MERGEFIELD myfield } bookmark the following line as "style3" and apply style "style3" to it: { MERGEFIELD myfield } and so on... then in your mail merge main document, use { INCLUDETEXT "c:\\include\\myfield.doc" "{ MERGEFIELD mystyle }" } However, I haven't checked and you may find that the style in the main document is used anyway. Peter Jamieson "Brendan" wrote in message ... I have a field in my database that stores an outline of topics covered in a course. The data is made up of headings and text. In my Word document I've created a new style called "heading3". Is there anyway to mark up the entries in the database field so that Word will know to apply "heading3" to the headings? |
#5
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Marking up data in Access to import in Word mail merge
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 |
#6
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Marking up data in Access to import in Word mail merge
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 |
#7
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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 |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Using Mail Merge to import Excel data to Word for printing checks | Mailmerge | |||
How do I import access data into a word mail merge document that | Mailmerge | |||
capitalization in word of access data via mail merge | Mailmerge | |||
How can I fix the Access data source of the mail merge for Word | Mailmerge | |||
import data into word from excel or access | Microsoft Word Help |