Hello,
I have a problem merging multiple word files. All together i am merging over 1000 files and using monarch to capture the data once in a single file. Everything was working fine until i reached the documents from 2003. In 2003 there was a change in the word document where a header has the Quote number and a jpeg file. I need the quote number from the header or the information is useless. currently my code looks like this:
Sub MergeFiles()
Dim files() As String
Dim num_files As Integer
Dim file_name As String
Dim dir_path As String
Dim file_ext As String
Dim i As Integer
dir_path = "S:\Information Technology\Development\Quotes\New Folder\"
file_ext = "doc"
file_name = Dir(dir_path & "\*." & file_ext)
Do While Len(file_name) > 0
ReDim Preserve files(0 To num_files)
files(num_files) = LCase(file_name)
file_name = Dir()
num_files = num_files + 1
Loop
Selection.EndKey Unit:=wdLine
For i = 0 To num_files - 1
With Selection
.InsertFile dir_path & files(i)
.EndKey Unit:=wdLine
.InsertBreak Type:=wdPageBreak
End With
Next i
End Sub
It still picks up all the information in the document but not in the header. I am not sure how to solve this problem.
Thanks in advance
I have a problem merging multiple word files. All together i am merging over 1000 files and using monarch to capture the data once in a single file. Everything was working fine until i reached the documents from 2003. In 2003 there was a change in the word document where a header has the Quote number and a jpeg file. I need the quote number from the header or the information is useless. currently my code looks like this:
Sub MergeFiles()
Dim files() As String
Dim num_files As Integer
Dim file_name As String
Dim dir_path As String
Dim file_ext As String
Dim i As Integer
dir_path = "S:\Information Technology\Development\Quotes\New Folder\"
file_ext = "doc"
file_name = Dir(dir_path & "\*." & file_ext)
Do While Len(file_name) > 0
ReDim Preserve files(0 To num_files)
files(num_files) = LCase(file_name)
file_name = Dir()
num_files = num_files + 1
Loop
Selection.EndKey Unit:=wdLine
For i = 0 To num_files - 1
With Selection
.InsertFile dir_path & files(i)
.EndKey Unit:=wdLine
.InsertBreak Type:=wdPageBreak
End With
Next i
End Sub
It still picks up all the information in the document but not in the header. I am not sure how to solve this problem.
Thanks in advance