Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
SlavetoWasabi SlavetoWasabi is offline
external usenet poster
 
Posts: 8
Default How do I merge several documents in one package and retain setting

I'm trying to do a mail merge where I assemble a package from several
different documents, which can vary depending on the scenario, then perform a
mail merge. Each of these documents may have different margins, headers,
header margins, etc. I currently have a blank "main" document that I insert
each file into, then perform the mail merge. Each document, before being
included in the main document, has a "Section Break - Next Page" at the
bottom. However, the settings reflected in each individual document are not
being retained in the merged product. Is there a way to do what I'm trying
to do?
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default How do I merge several documents in one package and retain setting

Are the settings of the individual documents retained in the mail merge main
document? How are you inserting the documents into the blank "main"
document - copy and paste or using an IncludeText field?

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in message
...
I'm trying to do a mail merge where I assemble a package from several
different documents, which can vary depending on the scenario, then
perform a
mail merge. Each of these documents may have different margins, headers,
header margins, etc. I currently have a blank "main" document that I
insert
each file into, then perform the mail merge. Each document, before being
included in the main document, has a "Section Break - Next Page" at the
bottom. However, the settings reflected in each individual document are
not
being retained in the merged product. Is there a way to do what I'm
trying
to do?


  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
SlavetoWasabi SlavetoWasabi is offline
external usenet poster
 
Posts: 8
Default How do I merge several documents in one package and retain set

Doug -

I'm using the InsertFile command to insert the documents:

WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True

Settings that seem to revert back to the main "blank" document settings
include margins and the spacing between the header and footer and the edge of
the paper.

Thanks,
Chris

"Doug Robbins - Word MVP" wrote:

Are the settings of the individual documents retained in the mail merge main
document? How are you inserting the documents into the blank "main"
document - copy and paste or using an IncludeText field?

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in message
...
I'm trying to do a mail merge where I assemble a package from several
different documents, which can vary depending on the scenario, then
perform a
mail merge. Each of these documents may have different margins, headers,
header margins, etc. I currently have a blank "main" document that I
insert
each file into, then perform the mail merge. Each document, before being
included in the main document, has a "Section Break - Next Page" at the
bottom. However, the settings reflected in each individual document are
not
being retained in the merged product. Is there a way to do what I'm
trying
to do?



  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default How do I merge several documents in one package and retain set

Best if you show us the complete code that you are using.

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in message
...
Doug -

I'm using the InsertFile command to insert the documents:

WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True

Settings that seem to revert back to the main "blank" document settings
include margins and the spacing between the header and footer and the edge
of
the paper.

Thanks,
Chris

"Doug Robbins - Word MVP" wrote:

Are the settings of the individual documents retained in the mail merge
main
document? How are you inserting the documents into the blank "main"
document - copy and paste or using an IncludeText field?

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
I'm trying to do a mail merge where I assemble a package from several
different documents, which can vary depending on the scenario, then
perform a
mail merge. Each of these documents may have different margins,
headers,
header margins, etc. I currently have a blank "main" document that I
insert
each file into, then perform the mail merge. Each document, before
being
included in the main document, has a "Section Break - Next Page" at the
bottom. However, the settings reflected in each individual document
are
not
being retained in the merged product. Is there a way to do what I'm
trying
to do?




  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
SlavetoWasabi SlavetoWasabi is offline
external usenet poster
 
Posts: 8
Default How do I merge several documents in one package and retain set

Doug -

Here's a code snippet. Some of this isn't relevant to the issue, but you
should have what you need in here.

Thanks again for your help,
Chris
************* Start of code snippet *************

'Start an Instance of Word, or grab an already-existing one
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err Then
Err.Clear
Set WordApp = GetObject("", "Word.Application")
End If

'Supress merge warning message about data, otherwise document not opened as
merge mail document
WordApp.DisplayAlerts = wdAlertsAll

'Hide Word until merging is complete,
WordApp.Visible = False
WordApp.WindowState = wdWindowStateMinimize

'Open master (blank) document
WordApp.Documents.Open FileName:=MainDocument, ReadOnly:=True

'Determine the name used by Word for the Main Document
'so that it can be closed after the Merge is completed
MainDocument = StrRev(MainDocument)
n = InStr(MainDocument, "\")
MainDocument = StrRev(MainDocument)
If n 0 Then
MainDocument = Right(MainDocument, n - 1)
End If

n = InStr(MainDocument, ".")
If n 0 Then
MainDocument = Left(MainDocument, n - 1)
End If

'Insert documents to be included in package into master document
For n = 0 To lstDocuments.ListCount - 1
If lstDocuments.Selected(n) = True Then
WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True
If Err Then
MsgBox "Unable to locate document: " & lstDocuments.List(n),
vbInformation
Err.Clear
End If
If n lstDocuments.SelCount - 1 Then
'Now including section break at the end of each document per message board
post
'in attempt to retain individual document formatting
' WordApp.Selection.InsertBreak wdSectionBreakNextPage
End If
End If
Next

'Indicate that the merge is to a new document (rather than the printer)
WordApp.ActiveDocument.MailMerge.Destination = wdSendToNewDocument
If Err Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If


'Perform the mail-merge
WordApp.ActiveDocument.MailMerge.Execute
If Err Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If

'Close the master document
g.LocateWordWindow WordApp, MainDocument
WordApp.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges


'Set focus to the window containing the merged document
g.LocateWordWindow WordApp, "Form Letters"


'View
If chkView.Value = 0 Then
WordApp.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Else
WordApp.Visible = True
WordApp.WindowState = wdWindowStateMaximize
End If


'Release the WordApp Object, and Exit
WordApp.Exit
Set WordApp = Nothing

******** End of Code Snippet **********

"Doug Robbins - Word MVP" wrote:

Best if you show us the complete code that you are using.

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in message
...
Doug -

I'm using the InsertFile command to insert the documents:

WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True

Settings that seem to revert back to the main "blank" document settings
include margins and the spacing between the header and footer and the edge
of
the paper.

Thanks,
Chris

"Doug Robbins - Word MVP" wrote:

Are the settings of the individual documents retained in the mail merge
main
document? How are you inserting the documents into the blank "main"
document - copy and paste or using an IncludeText field?

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
I'm trying to do a mail merge where I assemble a package from several
different documents, which can vary depending on the scenario, then
perform a
mail merge. Each of these documents may have different margins,
headers,
header margins, etc. I currently have a blank "main" document that I
insert
each file into, then perform the mail merge. Each document, before
being
included in the main document, has a "Section Break - Next Page" at the
bottom. However, the settings reflected in each individual document
are
not
being retained in the merged product. Is there a way to do what I'm
trying
to do?






  #6   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default How do I merge several documents in one package and retain set

Hi Chris,

Do it this way:

Dim Target As Document, Source As Document
Dim trange As Range, srange As Range
'Start an Instance of Word, or grab an already-existing one
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err Then
Err.Clear
Set WordApp = GetObject("", "Word.Application")
End If

'Supress merge warning message about data, otherwise document not opened as
merge mail document
WordApp.DisplayAlerts = wdAlertsAll

'Hide Word until merging is complete,
WordApp.Visible = False
WordApp.WindowState = wdWindowStateMinimize

'Open master (blank) document
Set Target = WordApp.Documents.Open(FileName:=MainDocument,
ReadOnly:=True)

'Determine the name used by Word for the Main Document
'so that it can be closed after the Merge is completed
MainDocument = StrRev(MainDocument)
n = InStr(MainDocument, "\")
MainDocument = StrRev(MainDocument)
If n 0 Then
MainDocument = Right(MainDocument, n - 1)
End If

n = InStr(MainDocument, ".")
If n 0 Then
MainDocument = Left(MainDocument, n - 1)
End If

'Insert documents to be included in package into master document
With Target
For n = 0 To lstDocuments.ListCount - 1
If lstDocuments.Selected(n) = True Then
Set Source = Documents.Open(lstDocuments.List(n))
If Err Then
MsgBox "Unable to locate document: " & lstDocuments.List(n),
vbInformation
Err.Clear
End If
With Source
Set srange = .Range
srange.Collapse wdCollapseEnd
srange.InsertBreak wdSectionBreakNextPage
End With
Set trange = .Range
trange.Collapse wdCollapseEnd
trange.FormattedText = Source.Range.FormattedText
Source.Close wdDoNotSaveChanges
End If
Next
'Change the next page section break at the end of the last document
inserted to a continuous section break
Set trange = .Range
trange.Collapse wdCollapseEnd
trange.Sections(1).PageSetup.SectionStart = wdSectionContinuous
End With


--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in message
...
Doug -

Here's a code snippet. Some of this isn't relevant to the issue, but you
should have what you need in here.

Thanks again for your help,
Chris
************* Start of code snippet *************

'Start an Instance of Word, or grab an already-existing one
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err Then
Err.Clear
Set WordApp = GetObject("", "Word.Application")
End If

'Supress merge warning message about data, otherwise document not opened
as
merge mail document
WordApp.DisplayAlerts = wdAlertsAll

'Hide Word until merging is complete,
WordApp.Visible = False
WordApp.WindowState = wdWindowStateMinimize

'Open master (blank) document
WordApp.Documents.Open FileName:=MainDocument, ReadOnly:=True

'Determine the name used by Word for the Main Document
'so that it can be closed after the Merge is completed
MainDocument = StrRev(MainDocument)
n = InStr(MainDocument, "\")
MainDocument = StrRev(MainDocument)
If n 0 Then
MainDocument = Right(MainDocument, n - 1)
End If

n = InStr(MainDocument, ".")
If n 0 Then
MainDocument = Left(MainDocument, n - 1)
End If

'Insert documents to be included in package into master document
For n = 0 To lstDocuments.ListCount - 1
If lstDocuments.Selected(n) = True Then
WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True
If Err Then
MsgBox "Unable to locate document: " & lstDocuments.List(n),
vbInformation
Err.Clear
End If
If n lstDocuments.SelCount - 1 Then
'Now including section break at the end of each document per message board
post
'in attempt to retain individual document formatting
' WordApp.Selection.InsertBreak wdSectionBreakNextPage
End If
End If
Next

'Indicate that the merge is to a new document (rather than the printer)
WordApp.ActiveDocument.MailMerge.Destination = wdSendToNewDocument
If Err Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If


'Perform the mail-merge
WordApp.ActiveDocument.MailMerge.Execute
If Err Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If

'Close the master document
g.LocateWordWindow WordApp, MainDocument
WordApp.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges


'Set focus to the window containing the merged document
g.LocateWordWindow WordApp, "Form Letters"


'View
If chkView.Value = 0 Then
WordApp.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Else
WordApp.Visible = True
WordApp.WindowState = wdWindowStateMaximize
End If


'Release the WordApp Object, and Exit
WordApp.Exit
Set WordApp = Nothing

******** End of Code Snippet **********

"Doug Robbins - Word MVP" wrote:

Best if you show us the complete code that you are using.

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
Doug -

I'm using the InsertFile command to insert the documents:

WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True

Settings that seem to revert back to the main "blank" document settings
include margins and the spacing between the header and footer and the
edge
of
the paper.

Thanks,
Chris

"Doug Robbins - Word MVP" wrote:

Are the settings of the individual documents retained in the mail
merge
main
document? How are you inserting the documents into the blank "main"
document - copy and paste or using an IncludeText field?

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
I'm trying to do a mail merge where I assemble a package from
several
different documents, which can vary depending on the scenario, then
perform a
mail merge. Each of these documents may have different margins,
headers,
header margins, etc. I currently have a blank "main" document that
I
insert
each file into, then perform the mail merge. Each document, before
being
included in the main document, has a "Section Break - Next Page" at
the
bottom. However, the settings reflected in each individual document
are
not
being retained in the merged product. Is there a way to do what I'm
trying
to do?





  #7   Report Post  
Posted to microsoft.public.word.mailmerge.fields
SlavetoWasabi SlavetoWasabi is offline
external usenet poster
 
Posts: 8
Default How do I merge several documents in one package and retain set

Doug -

One follow-up question. I'm noticing that in some instances the font in the
original document is not retained when the text is moved to the target
document. It appears that I can address this by using the Paste Options
button and selecting Retain original formatting. Is there a way I can
access this functionality programatically?

Thanks,
Chris

"Doug Robbins - Word MVP" wrote:

Hi Chris,

Do it this way:

Dim Target As Document, Source As Document
Dim trange As Range, srange As Range
'Start an Instance of Word, or grab an already-existing one
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err Then
Err.Clear
Set WordApp = GetObject("", "Word.Application")
End If

'Supress merge warning message about data, otherwise document not opened as
merge mail document
WordApp.DisplayAlerts = wdAlertsAll

'Hide Word until merging is complete,
WordApp.Visible = False
WordApp.WindowState = wdWindowStateMinimize

'Open master (blank) document
Set Target = WordApp.Documents.Open(FileName:=MainDocument,
ReadOnly:=True)

'Determine the name used by Word for the Main Document
'so that it can be closed after the Merge is completed
MainDocument = StrRev(MainDocument)
n = InStr(MainDocument, "\")
MainDocument = StrRev(MainDocument)
If n 0 Then
MainDocument = Right(MainDocument, n - 1)
End If

n = InStr(MainDocument, ".")
If n 0 Then
MainDocument = Left(MainDocument, n - 1)
End If

'Insert documents to be included in package into master document
With Target
For n = 0 To lstDocuments.ListCount - 1
If lstDocuments.Selected(n) = True Then
Set Source = Documents.Open(lstDocuments.List(n))
If Err Then
MsgBox "Unable to locate document: " & lstDocuments.List(n),
vbInformation
Err.Clear
End If
With Source
Set srange = .Range
srange.Collapse wdCollapseEnd
srange.InsertBreak wdSectionBreakNextPage
End With
Set trange = .Range
trange.Collapse wdCollapseEnd
trange.FormattedText = Source.Range.FormattedText
Source.Close wdDoNotSaveChanges
End If
Next
'Change the next page section break at the end of the last document
inserted to a continuous section break
Set trange = .Range
trange.Collapse wdCollapseEnd
trange.Sections(1).PageSetup.SectionStart = wdSectionContinuous
End With


--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in message
...
Doug -

Here's a code snippet. Some of this isn't relevant to the issue, but you
should have what you need in here.

Thanks again for your help,
Chris
************* Start of code snippet *************

'Start an Instance of Word, or grab an already-existing one
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err Then
Err.Clear
Set WordApp = GetObject("", "Word.Application")
End If

'Supress merge warning message about data, otherwise document not opened
as
merge mail document
WordApp.DisplayAlerts = wdAlertsAll

'Hide Word until merging is complete,
WordApp.Visible = False
WordApp.WindowState = wdWindowStateMinimize

'Open master (blank) document
WordApp.Documents.Open FileName:=MainDocument, ReadOnly:=True

'Determine the name used by Word for the Main Document
'so that it can be closed after the Merge is completed
MainDocument = StrRev(MainDocument)
n = InStr(MainDocument, "\")
MainDocument = StrRev(MainDocument)
If n 0 Then
MainDocument = Right(MainDocument, n - 1)
End If

n = InStr(MainDocument, ".")
If n 0 Then
MainDocument = Left(MainDocument, n - 1)
End If

'Insert documents to be included in package into master document
For n = 0 To lstDocuments.ListCount - 1
If lstDocuments.Selected(n) = True Then
WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True
If Err Then
MsgBox "Unable to locate document: " & lstDocuments.List(n),
vbInformation
Err.Clear
End If
If n lstDocuments.SelCount - 1 Then
'Now including section break at the end of each document per message board
post
'in attempt to retain individual document formatting
' WordApp.Selection.InsertBreak wdSectionBreakNextPage
End If
End If
Next

'Indicate that the merge is to a new document (rather than the printer)
WordApp.ActiveDocument.MailMerge.Destination = wdSendToNewDocument
If Err Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If


'Perform the mail-merge
WordApp.ActiveDocument.MailMerge.Execute
If Err Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If

'Close the master document
g.LocateWordWindow WordApp, MainDocument
WordApp.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges


'Set focus to the window containing the merged document
g.LocateWordWindow WordApp, "Form Letters"


'View
If chkView.Value = 0 Then
WordApp.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Else
WordApp.Visible = True
WordApp.WindowState = wdWindowStateMaximize
End If


'Release the WordApp Object, and Exit
WordApp.Exit
Set WordApp = Nothing

******** End of Code Snippet **********

"Doug Robbins - Word MVP" wrote:

Best if you show us the complete code that you are using.

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
Doug -

I'm using the InsertFile command to insert the documents:

WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True

Settings that seem to revert back to the main "blank" document settings
include margins and the spacing between the header and footer and the
edge
of
the paper.

Thanks,
Chris

"Doug Robbins - Word MVP" wrote:

Are the settings of the individual documents retained in the mail
merge
main
document? How are you inserting the documents into the blank "main"
document - copy and paste or using an IncludeText field?

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
I'm trying to do a mail merge where I assemble a package from
several
different documents, which can vary depending on the scenario, then
perform a
mail merge. Each of these documents may have different margins,
headers,
header margins, etc. I currently have a blank "main" document that
I
insert
each file into, then perform the mail merge. Each document, before
being
included in the main document, has a "Section Break - Next Page" at
the
bottom. However, the settings reflected in each individual document
are
not
being retained in the merged product. Is there a way to do what I'm
trying
to do?






  #8   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default How do I merge several documents in one package and retain set

Check that in the Modify Styles dialog that the Automatically Update Styles
box is not checked.

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in message
...
Doug -

One follow-up question. I'm noticing that in some instances the font in
the
original document is not retained when the text is moved to the target
document. It appears that I can address this by using the Paste Options
button and selecting Retain original formatting. Is there a way I can
access this functionality programatically?

Thanks,
Chris

"Doug Robbins - Word MVP" wrote:

Hi Chris,

Do it this way:

Dim Target As Document, Source As Document
Dim trange As Range, srange As Range
'Start an Instance of Word, or grab an already-existing one
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err Then
Err.Clear
Set WordApp = GetObject("", "Word.Application")
End If

'Supress merge warning message about data, otherwise document not opened
as
merge mail document
WordApp.DisplayAlerts = wdAlertsAll

'Hide Word until merging is complete,
WordApp.Visible = False
WordApp.WindowState = wdWindowStateMinimize

'Open master (blank) document
Set Target = WordApp.Documents.Open(FileName:=MainDocument,
ReadOnly:=True)

'Determine the name used by Word for the Main Document
'so that it can be closed after the Merge is completed
MainDocument = StrRev(MainDocument)
n = InStr(MainDocument, "\")
MainDocument = StrRev(MainDocument)
If n 0 Then
MainDocument = Right(MainDocument, n - 1)
End If

n = InStr(MainDocument, ".")
If n 0 Then
MainDocument = Left(MainDocument, n - 1)
End If

'Insert documents to be included in package into master document
With Target
For n = 0 To lstDocuments.ListCount - 1
If lstDocuments.Selected(n) = True Then
Set Source = Documents.Open(lstDocuments.List(n))
If Err Then
MsgBox "Unable to locate document: " &
lstDocuments.List(n),
vbInformation
Err.Clear
End If
With Source
Set srange = .Range
srange.Collapse wdCollapseEnd
srange.InsertBreak wdSectionBreakNextPage
End With
Set trange = .Range
trange.Collapse wdCollapseEnd
trange.FormattedText = Source.Range.FormattedText
Source.Close wdDoNotSaveChanges
End If
Next
'Change the next page section break at the end of the last document
inserted to a continuous section break
Set trange = .Range
trange.Collapse wdCollapseEnd
trange.Sections(1).PageSetup.SectionStart = wdSectionContinuous
End With


--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
Doug -

Here's a code snippet. Some of this isn't relevant to the issue, but
you
should have what you need in here.

Thanks again for your help,
Chris
************* Start of code snippet *************

'Start an Instance of Word, or grab an already-existing one
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err Then
Err.Clear
Set WordApp = GetObject("", "Word.Application")
End If

'Supress merge warning message about data, otherwise document not
opened
as
merge mail document
WordApp.DisplayAlerts = wdAlertsAll

'Hide Word until merging is complete,
WordApp.Visible = False
WordApp.WindowState = wdWindowStateMinimize

'Open master (blank) document
WordApp.Documents.Open FileName:=MainDocument, ReadOnly:=True

'Determine the name used by Word for the Main Document
'so that it can be closed after the Merge is completed
MainDocument = StrRev(MainDocument)
n = InStr(MainDocument, "\")
MainDocument = StrRev(MainDocument)
If n 0 Then
MainDocument = Right(MainDocument, n - 1)
End If

n = InStr(MainDocument, ".")
If n 0 Then
MainDocument = Left(MainDocument, n - 1)
End If

'Insert documents to be included in package into master document
For n = 0 To lstDocuments.ListCount - 1
If lstDocuments.Selected(n) = True Then
WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True
If Err Then
MsgBox "Unable to locate document: " & lstDocuments.List(n),
vbInformation
Err.Clear
End If
If n lstDocuments.SelCount - 1 Then
'Now including section break at the end of each document per message
board
post
'in attempt to retain individual document formatting
' WordApp.Selection.InsertBreak wdSectionBreakNextPage
End If
End If
Next

'Indicate that the merge is to a new document (rather than the printer)
WordApp.ActiveDocument.MailMerge.Destination = wdSendToNewDocument
If Err Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If


'Perform the mail-merge
WordApp.ActiveDocument.MailMerge.Execute
If Err Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If

'Close the master document
g.LocateWordWindow WordApp, MainDocument
WordApp.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges


'Set focus to the window containing the merged document
g.LocateWordWindow WordApp, "Form Letters"


'View
If chkView.Value = 0 Then
WordApp.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Else
WordApp.Visible = True
WordApp.WindowState = wdWindowStateMaximize
End If


'Release the WordApp Object, and Exit
WordApp.Exit
Set WordApp = Nothing

******** End of Code Snippet **********

"Doug Robbins - Word MVP" wrote:

Best if you show us the complete code that you are using.

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
Doug -

I'm using the InsertFile command to insert the documents:

WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True

Settings that seem to revert back to the main "blank" document
settings
include margins and the spacing between the header and footer and
the
edge
of
the paper.

Thanks,
Chris

"Doug Robbins - Word MVP" wrote:

Are the settings of the individual documents retained in the mail
merge
main
document? How are you inserting the documents into the blank
"main"
document - copy and paste or using an IncludeText field?

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
I'm trying to do a mail merge where I assemble a package from
several
different documents, which can vary depending on the scenario,
then
perform a
mail merge. Each of these documents may have different margins,
headers,
header margins, etc. I currently have a blank "main" document
that
I
insert
each file into, then perform the mail merge. Each document,
before
being
included in the main document, has a "Section Break - Next Page"
at
the
bottom. However, the settings reflected in each individual
document
are
not
being retained in the merged product. Is there a way to do what
I'm
trying
to do?







  #9   Report Post  
Posted to microsoft.public.word.mailmerge.fields
SlavetoWasabi SlavetoWasabi is offline
external usenet poster
 
Posts: 8
Default How do I merge several documents in one package and retain set

Doug -

That didn't seem to help. I had to upgrade to Office 2007 anyway, so I went
ahead and did that today. Still having the same problems, so I've been
trying out the pasting manually. I set all the default paste options under
the Advanced button to "Keep Source Formatting". However, when I do "Paste
Special", then "Formatted Text", the source formatting is not maintained and
when I click on the Paste Options icon that displays after the paste, the
paste option is always set to "Use Destination Styles". When I change it to
"Keep Source Formatting", then everything shows up the way I want it. I get
the same behavior from my automation. Interestingly enough, when I'm testing
the copy/paste out manually in Word, if I select "Paste" instead of "Paste
Special", it seems to be pasting with the "Keep Source Formatting" option,
and the document looks fine. What do I need to change in my automation to
replicate this behavior?

Thanks,
Chris

"Doug Robbins - Word MVP" wrote:

Check that in the Modify Styles dialog that the Automatically Update Styles
box is not checked.

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in message
...
Doug -

One follow-up question. I'm noticing that in some instances the font in
the
original document is not retained when the text is moved to the target
document. It appears that I can address this by using the Paste Options
button and selecting Retain original formatting. Is there a way I can
access this functionality programatically?

Thanks,
Chris

"Doug Robbins - Word MVP" wrote:

Hi Chris,

Do it this way:

Dim Target As Document, Source As Document
Dim trange As Range, srange As Range
'Start an Instance of Word, or grab an already-existing one
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err Then
Err.Clear
Set WordApp = GetObject("", "Word.Application")
End If

'Supress merge warning message about data, otherwise document not opened
as
merge mail document
WordApp.DisplayAlerts = wdAlertsAll

'Hide Word until merging is complete,
WordApp.Visible = False
WordApp.WindowState = wdWindowStateMinimize

'Open master (blank) document
Set Target = WordApp.Documents.Open(FileName:=MainDocument,
ReadOnly:=True)

'Determine the name used by Word for the Main Document
'so that it can be closed after the Merge is completed
MainDocument = StrRev(MainDocument)
n = InStr(MainDocument, "\")
MainDocument = StrRev(MainDocument)
If n 0 Then
MainDocument = Right(MainDocument, n - 1)
End If

n = InStr(MainDocument, ".")
If n 0 Then
MainDocument = Left(MainDocument, n - 1)
End If

'Insert documents to be included in package into master document
With Target
For n = 0 To lstDocuments.ListCount - 1
If lstDocuments.Selected(n) = True Then
Set Source = Documents.Open(lstDocuments.List(n))
If Err Then
MsgBox "Unable to locate document: " &
lstDocuments.List(n),
vbInformation
Err.Clear
End If
With Source
Set srange = .Range
srange.Collapse wdCollapseEnd
srange.InsertBreak wdSectionBreakNextPage
End With
Set trange = .Range
trange.Collapse wdCollapseEnd
trange.FormattedText = Source.Range.FormattedText
Source.Close wdDoNotSaveChanges
End If
Next
'Change the next page section break at the end of the last document
inserted to a continuous section break
Set trange = .Range
trange.Collapse wdCollapseEnd
trange.Sections(1).PageSetup.SectionStart = wdSectionContinuous
End With


--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
Doug -

Here's a code snippet. Some of this isn't relevant to the issue, but
you
should have what you need in here.

Thanks again for your help,
Chris
************* Start of code snippet *************

'Start an Instance of Word, or grab an already-existing one
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err Then
Err.Clear
Set WordApp = GetObject("", "Word.Application")
End If

'Supress merge warning message about data, otherwise document not
opened
as
merge mail document
WordApp.DisplayAlerts = wdAlertsAll

'Hide Word until merging is complete,
WordApp.Visible = False
WordApp.WindowState = wdWindowStateMinimize

'Open master (blank) document
WordApp.Documents.Open FileName:=MainDocument, ReadOnly:=True

'Determine the name used by Word for the Main Document
'so that it can be closed after the Merge is completed
MainDocument = StrRev(MainDocument)
n = InStr(MainDocument, "\")
MainDocument = StrRev(MainDocument)
If n 0 Then
MainDocument = Right(MainDocument, n - 1)
End If

n = InStr(MainDocument, ".")
If n 0 Then
MainDocument = Left(MainDocument, n - 1)
End If

'Insert documents to be included in package into master document
For n = 0 To lstDocuments.ListCount - 1
If lstDocuments.Selected(n) = True Then
WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True
If Err Then
MsgBox "Unable to locate document: " & lstDocuments.List(n),
vbInformation
Err.Clear
End If
If n lstDocuments.SelCount - 1 Then
'Now including section break at the end of each document per message
board
post
'in attempt to retain individual document formatting
' WordApp.Selection.InsertBreak wdSectionBreakNextPage
End If
End If
Next

'Indicate that the merge is to a new document (rather than the printer)
WordApp.ActiveDocument.MailMerge.Destination = wdSendToNewDocument
If Err Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If


'Perform the mail-merge
WordApp.ActiveDocument.MailMerge.Execute
If Err Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If

'Close the master document
g.LocateWordWindow WordApp, MainDocument
WordApp.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges


'Set focus to the window containing the merged document
g.LocateWordWindow WordApp, "Form Letters"


'View
If chkView.Value = 0 Then
WordApp.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Else
WordApp.Visible = True
WordApp.WindowState = wdWindowStateMaximize
End If


'Release the WordApp Object, and Exit
WordApp.Exit
Set WordApp = Nothing

******** End of Code Snippet **********

"Doug Robbins - Word MVP" wrote:

Best if you show us the complete code that you are using.

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
Doug -

I'm using the InsertFile command to insert the documents:

WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True

Settings that seem to revert back to the main "blank" document
settings
include margins and the spacing between the header and footer and
the
edge
of
the paper.

Thanks,
Chris

"Doug Robbins - Word MVP" wrote:

Are the settings of the individual documents retained in the mail
merge
main
document? How are you inserting the documents into the blank
"main"
document - copy and paste or using an IncludeText field?

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
I'm trying to do a mail merge where I assemble a package from
several
different documents, which can vary depending on the scenario,
then
perform a
mail merge. Each of these documents may have different margins,
headers,
header margins, etc. I currently have a blank "main" document
that
I
insert
each file into, then perform the mail merge. Each document,
before
being
included in the main document, has a "Section Break - Next Page"
at
the
bottom. However, the settings reflected in each individual
document
are
not
being retained in the merged product. Is there a way to do what
I'm
trying
to do?








  #10   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default How do I merge several documents in one package and retain set

Instead of the command

trange.FormattedText = Source.Range.FormattedText

try

Source.Range.Copy
trange.Paste

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in message
...
Doug -

That didn't seem to help. I had to upgrade to Office 2007 anyway, so I
went
ahead and did that today. Still having the same problems, so I've been
trying out the pasting manually. I set all the default paste options
under
the Advanced button to "Keep Source Formatting". However, when I do
"Paste
Special", then "Formatted Text", the source formatting is not maintained
and
when I click on the Paste Options icon that displays after the paste, the
paste option is always set to "Use Destination Styles". When I change it
to
"Keep Source Formatting", then everything shows up the way I want it. I
get
the same behavior from my automation. Interestingly enough, when I'm
testing
the copy/paste out manually in Word, if I select "Paste" instead of "Paste
Special", it seems to be pasting with the "Keep Source Formatting" option,
and the document looks fine. What do I need to change in my automation to
replicate this behavior?

Thanks,
Chris

"Doug Robbins - Word MVP" wrote:

Check that in the Modify Styles dialog that the Automatically Update
Styles
box is not checked.

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
Doug -

One follow-up question. I'm noticing that in some instances the font
in
the
original document is not retained when the text is moved to the target
document. It appears that I can address this by using the Paste
Options
button and selecting Retain original formatting. Is there a way I can
access this functionality programatically?

Thanks,
Chris

"Doug Robbins - Word MVP" wrote:

Hi Chris,

Do it this way:

Dim Target As Document, Source As Document
Dim trange As Range, srange As Range
'Start an Instance of Word, or grab an already-existing one
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err Then
Err.Clear
Set WordApp = GetObject("", "Word.Application")
End If

'Supress merge warning message about data, otherwise document not
opened
as
merge mail document
WordApp.DisplayAlerts = wdAlertsAll

'Hide Word until merging is complete,
WordApp.Visible = False
WordApp.WindowState = wdWindowStateMinimize

'Open master (blank) document
Set Target = WordApp.Documents.Open(FileName:=MainDocument,
ReadOnly:=True)

'Determine the name used by Word for the Main Document
'so that it can be closed after the Merge is completed
MainDocument = StrRev(MainDocument)
n = InStr(MainDocument, "\")
MainDocument = StrRev(MainDocument)
If n 0 Then
MainDocument = Right(MainDocument, n - 1)
End If

n = InStr(MainDocument, ".")
If n 0 Then
MainDocument = Left(MainDocument, n - 1)
End If

'Insert documents to be included in package into master document
With Target
For n = 0 To lstDocuments.ListCount - 1
If lstDocuments.Selected(n) = True Then
Set Source = Documents.Open(lstDocuments.List(n))
If Err Then
MsgBox "Unable to locate document: " &
lstDocuments.List(n),
vbInformation
Err.Clear
End If
With Source
Set srange = .Range
srange.Collapse wdCollapseEnd
srange.InsertBreak wdSectionBreakNextPage
End With
Set trange = .Range
trange.Collapse wdCollapseEnd
trange.FormattedText = Source.Range.FormattedText
Source.Close wdDoNotSaveChanges
End If
Next
'Change the next page section break at the end of the last
document
inserted to a continuous section break
Set trange = .Range
trange.Collapse wdCollapseEnd
trange.Sections(1).PageSetup.SectionStart = wdSectionContinuous
End With


--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
Doug -

Here's a code snippet. Some of this isn't relevant to the issue,
but
you
should have what you need in here.

Thanks again for your help,
Chris
************* Start of code snippet *************

'Start an Instance of Word, or grab an already-existing one
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err Then
Err.Clear
Set WordApp = GetObject("", "Word.Application")
End If

'Supress merge warning message about data, otherwise document not
opened
as
merge mail document
WordApp.DisplayAlerts = wdAlertsAll

'Hide Word until merging is complete,
WordApp.Visible = False
WordApp.WindowState = wdWindowStateMinimize

'Open master (blank) document
WordApp.Documents.Open FileName:=MainDocument, ReadOnly:=True

'Determine the name used by Word for the Main Document
'so that it can be closed after the Merge is completed
MainDocument = StrRev(MainDocument)
n = InStr(MainDocument, "\")
MainDocument = StrRev(MainDocument)
If n 0 Then
MainDocument = Right(MainDocument, n - 1)
End If

n = InStr(MainDocument, ".")
If n 0 Then
MainDocument = Left(MainDocument, n - 1)
End If

'Insert documents to be included in package into master document
For n = 0 To lstDocuments.ListCount - 1
If lstDocuments.Selected(n) = True Then
WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True
If Err Then
MsgBox "Unable to locate document: " &
lstDocuments.List(n),
vbInformation
Err.Clear
End If
If n lstDocuments.SelCount - 1 Then
'Now including section break at the end of each document per message
board
post
'in attempt to retain individual document formatting
' WordApp.Selection.InsertBreak wdSectionBreakNextPage
End If
End If
Next

'Indicate that the merge is to a new document (rather than the
printer)
WordApp.ActiveDocument.MailMerge.Destination = wdSendToNewDocument
If Err Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If


'Perform the mail-merge
WordApp.ActiveDocument.MailMerge.Execute
If Err Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If

'Close the master document
g.LocateWordWindow WordApp, MainDocument
WordApp.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges


'Set focus to the window containing the merged document
g.LocateWordWindow WordApp, "Form Letters"


'View
If chkView.Value = 0 Then
WordApp.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Else
WordApp.Visible = True
WordApp.WindowState = wdWindowStateMaximize
End If


'Release the WordApp Object, and Exit
WordApp.Exit
Set WordApp = Nothing

******** End of Code Snippet **********

"Doug Robbins - Word MVP" wrote:

Best if you show us the complete code that you are using.

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
Doug -

I'm using the InsertFile command to insert the documents:

WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True

Settings that seem to revert back to the main "blank" document
settings
include margins and the spacing between the header and footer and
the
edge
of
the paper.

Thanks,
Chris

"Doug Robbins - Word MVP" wrote:

Are the settings of the individual documents retained in the
mail
merge
main
document? How are you inserting the documents into the blank
"main"
document - copy and paste or using an IncludeText field?

--
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, originally posted via
msnews.microsoft.com
"SlavetoWasabi" wrote
in
message
...
I'm trying to do a mail merge where I assemble a package from
several
different documents, which can vary depending on the scenario,
then
perform a
mail merge. Each of these documents may have different
margins,
headers,
header margins, etc. I currently have a blank "main" document
that
I
insert
each file into, then perform the mail merge. Each document,
before
being
included in the main document, has a "Section Break - Next
Page"
at
the
bottom. However, the settings reflected in each individual
document
are
not
being retained in the merged product. Is there a way to do
what
I'm
trying
to do?











  #11   Report Post  
Posted to microsoft.public.word.mailmerge.fields
SlavetoWasabi SlavetoWasabi is offline
external usenet poster
 
Posts: 8
Default How do I merge several documents in one package and retain set

Doug -

That resulted in the same behavior, but this command seems to have worked:

trange.PasteAndFormat (wdFormatOriginalFormatting)

I turned on the macro recording, and that's the command that Word was using
when I clicked on "Paste".

Thanks again for all your help,
Chris

"Doug Robbins - Word MVP" wrote:

Instead of the command

trange.FormattedText = Source.Range.FormattedText

try

Source.Range.Copy
trange.Paste

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in message
...
Doug -

That didn't seem to help. I had to upgrade to Office 2007 anyway, so I
went
ahead and did that today. Still having the same problems, so I've been
trying out the pasting manually. I set all the default paste options
under
the Advanced button to "Keep Source Formatting". However, when I do
"Paste
Special", then "Formatted Text", the source formatting is not maintained
and
when I click on the Paste Options icon that displays after the paste, the
paste option is always set to "Use Destination Styles". When I change it
to
"Keep Source Formatting", then everything shows up the way I want it. I
get
the same behavior from my automation. Interestingly enough, when I'm
testing
the copy/paste out manually in Word, if I select "Paste" instead of "Paste
Special", it seems to be pasting with the "Keep Source Formatting" option,
and the document looks fine. What do I need to change in my automation to
replicate this behavior?

Thanks,
Chris

"Doug Robbins - Word MVP" wrote:

Check that in the Modify Styles dialog that the Automatically Update
Styles
box is not checked.

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
Doug -

One follow-up question. I'm noticing that in some instances the font
in
the
original document is not retained when the text is moved to the target
document. It appears that I can address this by using the Paste
Options
button and selecting Retain original formatting. Is there a way I can
access this functionality programatically?

Thanks,
Chris

"Doug Robbins - Word MVP" wrote:

Hi Chris,

Do it this way:

Dim Target As Document, Source As Document
Dim trange As Range, srange As Range
'Start an Instance of Word, or grab an already-existing one
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err Then
Err.Clear
Set WordApp = GetObject("", "Word.Application")
End If

'Supress merge warning message about data, otherwise document not
opened
as
merge mail document
WordApp.DisplayAlerts = wdAlertsAll

'Hide Word until merging is complete,
WordApp.Visible = False
WordApp.WindowState = wdWindowStateMinimize

'Open master (blank) document
Set Target = WordApp.Documents.Open(FileName:=MainDocument,
ReadOnly:=True)

'Determine the name used by Word for the Main Document
'so that it can be closed after the Merge is completed
MainDocument = StrRev(MainDocument)
n = InStr(MainDocument, "\")
MainDocument = StrRev(MainDocument)
If n 0 Then
MainDocument = Right(MainDocument, n - 1)
End If

n = InStr(MainDocument, ".")
If n 0 Then
MainDocument = Left(MainDocument, n - 1)
End If

'Insert documents to be included in package into master document
With Target
For n = 0 To lstDocuments.ListCount - 1
If lstDocuments.Selected(n) = True Then
Set Source = Documents.Open(lstDocuments.List(n))
If Err Then
MsgBox "Unable to locate document: " &
lstDocuments.List(n),
vbInformation
Err.Clear
End If
With Source
Set srange = .Range
srange.Collapse wdCollapseEnd
srange.InsertBreak wdSectionBreakNextPage
End With
Set trange = .Range
trange.Collapse wdCollapseEnd
trange.FormattedText = Source.Range.FormattedText
Source.Close wdDoNotSaveChanges
End If
Next
'Change the next page section break at the end of the last
document
inserted to a continuous section break
Set trange = .Range
trange.Collapse wdCollapseEnd
trange.Sections(1).PageSetup.SectionStart = wdSectionContinuous
End With


--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
Doug -

Here's a code snippet. Some of this isn't relevant to the issue,
but
you
should have what you need in here.

Thanks again for your help,
Chris
************* Start of code snippet *************

'Start an Instance of Word, or grab an already-existing one
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err Then
Err.Clear
Set WordApp = GetObject("", "Word.Application")
End If

'Supress merge warning message about data, otherwise document not
opened
as
merge mail document
WordApp.DisplayAlerts = wdAlertsAll

'Hide Word until merging is complete,
WordApp.Visible = False
WordApp.WindowState = wdWindowStateMinimize

'Open master (blank) document
WordApp.Documents.Open FileName:=MainDocument, ReadOnly:=True

'Determine the name used by Word for the Main Document
'so that it can be closed after the Merge is completed
MainDocument = StrRev(MainDocument)
n = InStr(MainDocument, "\")
MainDocument = StrRev(MainDocument)
If n 0 Then
MainDocument = Right(MainDocument, n - 1)
End If

n = InStr(MainDocument, ".")
If n 0 Then
MainDocument = Left(MainDocument, n - 1)
End If

'Insert documents to be included in package into master document
For n = 0 To lstDocuments.ListCount - 1
If lstDocuments.Selected(n) = True Then
WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True
If Err Then
MsgBox "Unable to locate document: " &
lstDocuments.List(n),
vbInformation
Err.Clear
End If
If n lstDocuments.SelCount - 1 Then
'Now including section break at the end of each document per message
board
post
'in attempt to retain individual document formatting
' WordApp.Selection.InsertBreak wdSectionBreakNextPage
End If
End If
Next

'Indicate that the merge is to a new document (rather than the
printer)
WordApp.ActiveDocument.MailMerge.Destination = wdSendToNewDocument
If Err Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If


'Perform the mail-merge
WordApp.ActiveDocument.MailMerge.Execute
If Err Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If

'Close the master document
g.LocateWordWindow WordApp, MainDocument
WordApp.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges


'Set focus to the window containing the merged document
g.LocateWordWindow WordApp, "Form Letters"


'View
If chkView.Value = 0 Then
WordApp.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Else
WordApp.Visible = True
WordApp.WindowState = wdWindowStateMaximize
End If


'Release the WordApp Object, and Exit
WordApp.Exit
Set WordApp = Nothing

******** End of Code Snippet **********

"Doug Robbins - Word MVP" wrote:

Best if you show us the complete code that you are using.

--
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, originally posted via msnews.microsoft.com
"SlavetoWasabi" wrote in
message
...
Doug -

I'm using the InsertFile command to insert the documents:

WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True

Settings that seem to revert back to the main "blank" document
settings
include margins and the spacing between the header and footer and
the
edge
of
the paper.

Thanks,
Chris

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
How do I retain the original date on word documents? hebden Microsoft Word Help 2 March 13th 09 07:57 PM
Word 2007: how to retain the zoom level setting for incoming mail comet270 Microsoft Word Help 1 July 11th 08 01:41 PM
Switches in Table of Authorities - retain formatting does not retain character styles Charles Kenyon Formatting Long Documents 1 March 28th 06 10:06 AM
Word 2003 does not retain top margin setting MS Word default settings not retained Page Layout 1 September 7th 05 07:08 PM
How to retain a format change during a merge Sagit Mailmerge 3 August 23rd 05 02:58 PM


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