Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge Files

Status
Not open for further replies.

BenTitus

Programmer
Jan 16, 2003
61
US
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
 
Hi,

It would seem to me that you would begin with the most inclusive definition of the data that you will be accessing and build the application around that definition.

Since everything prior to 2003 has a different header, your file break ought to be a section break on next page and NOT a page break. Then the section property ought to be something like...
Code:
    Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
        LinkToPrevious
Hope this helps :)

Skip,
Skip@TheOfficeExperts.com
 
whenever i try what you suggested i keep getting a run time error about the object. Right now i have everything seperated into 3 folders. 2001, 2002, and 2003. 2001 and 2002 i have merged into their own single files but 2003 is where a header has been created in the word documents. I still pick up the information except for the header. i don't know if i explained my problem clear enough before.
thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top