Help:VBA in Office '03

woodchuckwood

Registered User.
Local time
Today, 15:17
Joined
Jan 15, 2004
Messages
10
I've used this line of code in word 2000 (works like a charm), but it does not work for '03.


Sub insert()

Dim file As String


ChDir ("C:\test")
file = Dir("*.doc")
Do While file <> ""
With Selection
.InsertFile FileName:=file, Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False

.InsertBreak Type:=wdSectionBreakNextPage

End With
file = Dir()
Loop

End Sub

It does not like the " ChDir ("C:\test") " line. Is there a way around this?
 
Did you try this...

Sub insert()

Dim file As String

file = Dir("C:\test\*.doc")
Do While file <> ""
With Selection
.InsertFile FileName:=file, Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False

.InsertBreak Type:=wdSectionBreakNextPage

End With
file = Dir()
Loop

End Sub
 

Users who are viewing this thread

Back
Top Bottom