Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Philip Ruelle
 
Posts: n/a
Default Mailmerge Formatting Problems

Hi,

Like many others before, I am trying to use automation to split a mail
merge Word file. I've searched the groups and found several solutions
but they all seem to have a fatal flaw.

The creation of the separate files works fine but each file has the
trailing section break in it. I've tried doing a MoveUp followed by a
Delete. I've tried doing a find and replace on the "^b" character. But
they both end up with the formatting being lost.

I know that sections contain the header/footer information, page setup,
etc but I'd have thought the first section's setup would be stored in
the implicit first section and the section break next page would hold
the information for the second, empty section. So I am surprised that
deleting the second section has any effect on the first section.

Does anyone know how to get around this problem? Is there something
obvious I'm missing like a 'retain formatting' flag? I've tried
grabbling the PageSetup object prior to removing the trailing sction
break and then re-applying it again afterwards but that does not work.
The only file in which the formatting remains correct is the last one
and that is the only one that does not have a trailing section break.

Any suggestions gratefully received,
Phil

N.B. I am writing code in C# and accessing the Word functionality via
the Microsoft.Office.Interop.Word wrapper.

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP
 
Posts: n/a
Default Mailmerge Formatting Problems

This macro changes the section break at the end of each document resulting
from splitting mail merge to a continuous section break so that it does not
cause a blank page (unless the last page containing text is full to the
gills).

Sub splitter()
' splitter Macro
' Macro created by Doug Robbins to save each letter created by a mailmerge
' as a separate file, retaining the header and footer information.
Dim i As Long, Source As Document, Target As Document, Letter As Range
Set Source = ActiveDocument
For i = 1 To Source.Sections.Count
Set Letter = Source.Sections(i).Range
Set Target = Documents.Add
Target.Range = Letter
Target.Sections(2).PageSetup.SectionStart = wdSectionContinuous
Target.SaveAs FileName:="Letter" & i
Target.Close
Next i
End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Philip Ruelle" wrote in message
oups.com...
Hi,

Like many others before, I am trying to use automation to split a mail
merge Word file. I've searched the groups and found several solutions
but they all seem to have a fatal flaw.

The creation of the separate files works fine but each file has the
trailing section break in it. I've tried doing a MoveUp followed by a
Delete. I've tried doing a find and replace on the "^b" character. But
they both end up with the formatting being lost.

I know that sections contain the header/footer information, page setup,
etc but I'd have thought the first section's setup would be stored in
the implicit first section and the section break next page would hold
the information for the second, empty section. So I am surprised that
deleting the second section has any effect on the first section.

Does anyone know how to get around this problem? Is there something
obvious I'm missing like a 'retain formatting' flag? I've tried
grabbling the PageSetup object prior to removing the trailing sction
break and then re-applying it again afterwards but that does not work.
The only file in which the formatting remains correct is the last one
and that is the only one that does not have a trailing section break.

Any suggestions gratefully received,
Phil

N.B. I am writing code in C# and accessing the Word functionality via
the Microsoft.Office.Interop.Word wrapper.



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Philip Ruelle
 
Posts: n/a
Default Mailmerge Formatting Problems

Fantastic, thanks Doug, I've tried it out and it works like a charm.

I don't think the spurious section break will cause me any issues but
out of interest is it possible to completely remove the section break
or is this the only way to get the desired results?

Thanks,
Phil

Doug Robbins - Word MVP wrote:
This macro changes the section break at the end of each document resulting
from splitting mail merge to a continuous section break so that it does not
cause a blank page (unless the last page containing text is full to the
gills).

Sub splitter()
' splitter Macro
' Macro created by Doug Robbins to save each letter created by a mailmerge
' as a separate file, retaining the header and footer information.
Dim i As Long, Source As Document, Target As Document, Letter As Range
Set Source = ActiveDocument
For i = 1 To Source.Sections.Count
Set Letter = Source.Sections(i).Range
Set Target = Documents.Add
Target.Range = Letter
Target.Sections(2).PageSetup.SectionStart = wdSectionContinuous
Target.SaveAs FileName:="Letter" & i
Target.Close
Next i
End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Philip Ruelle" wrote in message
oups.com...
Hi,

Like many others before, I am trying to use automation to split a mail
merge Word file. I've searched the groups and found several solutions
but they all seem to have a fatal flaw.

The creation of the separate files works fine but each file has the
trailing section break in it. I've tried doing a MoveUp followed by a
Delete. I've tried doing a find and replace on the "^b" character. But
they both end up with the formatting being lost.

I know that sections contain the header/footer information, page setup,
etc but I'd have thought the first section's setup would be stored in
the implicit first section and the section break next page would hold
the information for the second, empty section. So I am surprised that
deleting the second section has any effect on the first section.

Does anyone know how to get around this problem? Is there something
obvious I'm missing like a 'retain formatting' flag? I've tried
grabbling the PageSetup object prior to removing the trailing sction
break and then re-applying it again afterwards but that does not work.
The only file in which the formatting remains correct is the last one
and that is the only one that does not have a trailing section break.

Any suggestions gratefully received,
Phil

N.B. I am writing code in C# and accessing the Word functionality via
the Microsoft.Office.Interop.Word wrapper.


  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP
 
Posts: n/a
Default Mailmerge Formatting Problems

The only way would be to use VBA to reconstruct the
headers/footers/pagelayout as would be required after deleting the section
break.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Philip Ruelle" wrote in message
oups.com...
Fantastic, thanks Doug, I've tried it out and it works like a charm.

I don't think the spurious section break will cause me any issues but
out of interest is it possible to completely remove the section break
or is this the only way to get the desired results?

Thanks,
Phil

Doug Robbins - Word MVP wrote:
This macro changes the section break at the end of each document
resulting
from splitting mail merge to a continuous section break so that it does
not
cause a blank page (unless the last page containing text is full to the
gills).

Sub splitter()
' splitter Macro
' Macro created by Doug Robbins to save each letter created by a
mailmerge
' as a separate file, retaining the header and footer information.
Dim i As Long, Source As Document, Target As Document, Letter As Range
Set Source = ActiveDocument
For i = 1 To Source.Sections.Count
Set Letter = Source.Sections(i).Range
Set Target = Documents.Add
Target.Range = Letter
Target.Sections(2).PageSetup.SectionStart = wdSectionContinuous
Target.SaveAs FileName:="Letter" & i
Target.Close
Next i
End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Philip Ruelle" wrote in message
oups.com...
Hi,

Like many others before, I am trying to use automation to split a mail
merge Word file. I've searched the groups and found several solutions
but they all seem to have a fatal flaw.

The creation of the separate files works fine but each file has the
trailing section break in it. I've tried doing a MoveUp followed by a
Delete. I've tried doing a find and replace on the "^b" character. But
they both end up with the formatting being lost.

I know that sections contain the header/footer information, page setup,
etc but I'd have thought the first section's setup would be stored in
the implicit first section and the section break next page would hold
the information for the second, empty section. So I am surprised that
deleting the second section has any effect on the first section.

Does anyone know how to get around this problem? Is there something
obvious I'm missing like a 'retain formatting' flag? I've tried
grabbling the PageSetup object prior to removing the trailing sction
break and then re-applying it again afterwards but that does not work.
The only file in which the formatting remains correct is the last one
and that is the only one that does not have a trailing section break.

Any suggestions gratefully received,
Phil

N.B. I am writing code in C# and accessing the Word functionality via
the Microsoft.Office.Interop.Word wrapper.




Reply
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
Formatting Problems - light gray paragraph marks appear kapy3 Microsoft Word Help 3 July 20th 05 05:22 AM
Problems with formatting GWLewis Microsoft Word Help 1 June 16th 05 05:21 PM
Formatting a word mailmerge with Excel data source Tracey Mailmerge 2 March 15th 05 02:07 PM
Form Fields lose bold formatting Ellen Microsoft Word Help 0 February 17th 05 09:11 PM
Problems migrating Word 97 mailmerge document to Word 2003 [email protected] Mailmerge 2 January 18th 05 07:03 PM


All times are GMT +1. The time now is 08:15 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"