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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge Multiple word files into single document

Status
Not open for further replies.

BenTitus

Programmer
Jan 16, 2003
61
0
0
US
Hello i have been searching on the net for a way to merge multiple word documents into a single file. From there I plan on using Monarch to extract the necissary data. I do not have VB 6.0 or .net on my computer, all i have is access. I created a form with a command button and used some code i found on the net. it looks like this:

Private Sub CommandButton1_Click()
Call MergeFiles
End Sub
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

I keep getting an error at Selection.EndKey ... I am not framiliar with Selection.EndKey so i do not know how to go about solving this error. Does anyone have any suggestions?
Thanks in advance
 
Hi,

You try to use Word VBA in Access. Use instead the Visual Basic Editor of Word.

jp@solutionsvba.com


Jean-Paul
Montreal
mtljp2@sympatico.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top