R
Rocco
question:
I know how to insert multiple documents and an example is also in the list
below.
Only problem is that when using this method headers and footers are not
retained.
this is caused by the sameasprevious when inserting a sectionbreaknextpage
at the end of of each document.
This means that when I insert for example the second document the header and
footer of the first are being used for the second document.
This is the code from steve lang, only thing adapted is the pagebreak that
is now a sectionbreak, this is needed to keep pagesettings correct:
Sub Foo()
Dim i As Long
Application.ScreenUpdating = False
Documents.Add
With Application.FileSearch
'Search in foldername
.LookIn = "C:\test"
.SearchSubFolders = False
.FileName = "*.doc"
.Execute
For i = 1 To .FoundFiles.Count
If InStr(.FoundFiles(i), "~") = 0 Then
Selection.InsertFile FileName:=(.FoundFiles(i)), _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.InsertBreak Type:=wdsectionBreaknextpage
End If
Next i
End With
End Sub
turning off sameasprevious after inserting the doesn't help very much
because at that point the header and footer of the first document are already
used.
Maybe there is a way, that I don't know to bring them back into the previous
state
If been trying all kinds of stuff to get this to work, nothing seems to work
only thing that did work was using a maindocuments and add subdocuments to
it but this was way to slow when you need to append for example 1000
documents.
Please help me on this issue,
I know how to insert multiple documents and an example is also in the list
below.
Only problem is that when using this method headers and footers are not
retained.
this is caused by the sameasprevious when inserting a sectionbreaknextpage
at the end of of each document.
This means that when I insert for example the second document the header and
footer of the first are being used for the second document.
This is the code from steve lang, only thing adapted is the pagebreak that
is now a sectionbreak, this is needed to keep pagesettings correct:
Sub Foo()
Dim i As Long
Application.ScreenUpdating = False
Documents.Add
With Application.FileSearch
'Search in foldername
.LookIn = "C:\test"
.SearchSubFolders = False
.FileName = "*.doc"
.Execute
For i = 1 To .FoundFiles.Count
If InStr(.FoundFiles(i), "~") = 0 Then
Selection.InsertFile FileName:=(.FoundFiles(i)), _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.InsertBreak Type:=wdsectionBreaknextpage
End If
Next i
End With
End Sub
turning off sameasprevious after inserting the doesn't help very much
because at that point the header and footer of the first document are already
used.
Maybe there is a way, that I don't know to bring them back into the previous
state
If been trying all kinds of stuff to get this to work, nothing seems to work
only thing that did work was using a maindocuments and add subdocuments to
it but this was way to slow when you need to append for example 1000
documents.
Please help me on this issue,