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
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