G
Gary Cassidy
I have a folder with nearly 100 documents that I want joined into one.
I cobbled together the following code based on several past posts I
found but I have not been able to successfully run it. The best has
been about 8 documents that get inserted before the macro crashes with a
message stating "Code execution has been interupted" When I choose
"debug", the line which inserts a page break is highlighted.
Any ideas?
Sub JoinFiles()
Dim xFile As String
Documents.Add
' Get files one at a time.
xFile = Dir$("c:\ACMDP2\*.doc")
Do While xFile <> ""
' Insert first file
Selection.InsertFile FileName:="c:\ACMDP2\" & xFile
Selection.InsertBreak Type:=wdSectionBreakNextPage
Selection.Collapse Direction:=wdCollapseEnd
' Get next file
xFile = Dir$()
Loop
End Sub
Thanks
Gary
I cobbled together the following code based on several past posts I
found but I have not been able to successfully run it. The best has
been about 8 documents that get inserted before the macro crashes with a
message stating "Code execution has been interupted" When I choose
"debug", the line which inserts a page break is highlighted.
Any ideas?
Sub JoinFiles()
Dim xFile As String
Documents.Add
' Get files one at a time.
xFile = Dir$("c:\ACMDP2\*.doc")
Do While xFile <> ""
' Insert first file
Selection.InsertFile FileName:="c:\ACMDP2\" & xFile
Selection.InsertBreak Type:=wdSectionBreakNextPage
Selection.Collapse Direction:=wdCollapseEnd
' Get next file
xFile = Dir$()
Loop
End Sub
Thanks
Gary