vb code debug ; combining many docs into one

S

sals

Hi,

I copied this code from one of the posts and tried to run it but am
getting an error on these lines:

'If activeDir = "" Then
' activeDir = getFullPath(UCase(fileType) & "|*." &
UCase(fileType))
'End If

from these code...

Sub concatFiles()
Dim resp As Integer
Dim activeDir As String
Dim fileType As String

resp = MsgBox("This macro concatenates all DOC files in the
directory you select next.", vbOKCancel)
If resp = vbCancel Then Exit Sub

fileType = "doc"
If activeDir = "" Then
activeDir = getFullPath(UCase(fileType) & "|*." &
UCase(fileType))
End If
If activeDir <> "" Then
With Application.FileSearch
.NewSearch
.LookIn = activeDir
.SearchSubFolders = False
.FileName = "*." & fileType
.MatchTextExactly = False
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Selection.InsertBreak Type:=wdSectionBreakOddPage
Selection.InsertFile FileName:=.FoundFiles(i),
Range:="", ConfirmConversions:=False, Link:=False, Attachment:=False
Next i
Else
MsgBox "There were no files found to concatenate."
End If
End With
Else
Exit Sub
End If
MsgBox "Concatenated " & i - 1 & " files."
End Sub



Can anyone tell me why it doesn't seem to be picking up getFullPath
method?
Thanks,

S
 
A

Anne Troy

Seems to me that you have the pipe character there: "|*." and perhaps it
should be a slash.
<-*-><-*-><-*-><-*-><-*-><-*-><-*-><-*->
Hope this helps!
Anne Troy (better known as Dreamboat)
Web: www.VBAExpress.com
<-*-><-*-><-*-><-*-><-*-><-*-><-*-><-*->
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top