K
kyle
I found this post and tried the method described using the following
macro code:
________________________________________
Dim mydoc As Document
Dim target As Document
Dim i As Long
'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() <> -1 Then Exit Sub
MyPath = .Directory
End With
'strip quotation marks from path
Set target = Documents.Add
If Len(MyPath) = 0 Then Exit Sub
If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If
'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.*")
Do While MyName <> ""
Set mydoc = Documents.Open(MyPath & MyName)
For i = 1 To mydoc.FormFields.Count - 1
target.Range.InsertAfter mydoc.FormFields(i).result & vbTab
Next i
target.Range.InsertAfter mydoc.FormFields(i).result & vbCr
mydoc.Close wdDoNotSaveChanges
MyName = Dir$
Loop
__________________________________________
But have recieved an error when trying to run it. The error is:
______________________________
Compile Error:
Invalid outside procedure
______________________________
which then highlights this line of code:
______________________________
With Dialogs(wdDialogCopyFile)
______________________________
I am using excel 2003 on xp pro with all the latest updates and such.
Anyone have an idea why the
macro code:
________________________________________
Dim mydoc As Document
Dim target As Document
Dim i As Long
'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() <> -1 Then Exit Sub
MyPath = .Directory
End With
'strip quotation marks from path
Set target = Documents.Add
If Len(MyPath) = 0 Then Exit Sub
If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If
'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.*")
Do While MyName <> ""
Set mydoc = Documents.Open(MyPath & MyName)
For i = 1 To mydoc.FormFields.Count - 1
target.Range.InsertAfter mydoc.FormFields(i).result & vbTab
Next i
target.Range.InsertAfter mydoc.FormFields(i).result & vbCr
mydoc.Close wdDoNotSaveChanges
MyName = Dir$
Loop
__________________________________________
But have recieved an error when trying to run it. The error is:
______________________________
Compile Error:
Invalid outside procedure
______________________________
which then highlights this line of code:
______________________________
With Dialogs(wdDialogCopyFile)
______________________________
I am using excel 2003 on xp pro with all the latest updates and such.
Anyone have an idea why the