Import multiple files macro can't find files

  • Thread starter Thread starter Steven Rosenberg
  • Start date Start date
S

Steven Rosenberg

I recently wrote a macro which imported 36 files into the
same MSWord document. It worked fine when the day I
wrote it, but today ithe error message "file can't be
found" appears. And now, just as I began writing this,
the Macro began working again. Said Macro is below.
What determines where the macro looks for these files
(which folder/directory?)

Steven

Sub Insert36()
'
' Insert36 Macro
' Macro recorded 7/30/03 by Karen Demelio
'
Selection.InsertFile FileName:="001", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="02", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="03", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="04", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="05", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="06", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="07", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="08", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="09", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="10", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="11", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="12", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="13", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="14", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="15", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="16", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="17", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="18", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="19", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="20", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="21", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="22", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="23", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="24", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="25", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="26", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="27", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="28", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="29", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="30", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="31", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="32", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="33", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="34", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="35", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
Selection.InsertFile FileName:="36", Range:="",
ConfirmConversions:=False, _
Link:=False, Attachment:=False
End Sub
 
Steven.

... you didn't write it you recorded it... :)

and it could be done a bit simpler.

Sub Insert36()
Dim sFldr as String
Dim i as Integer

If msgbox ("will read from folder " & vba.curdir) <> vbOk then exit sub
For i = 1 to 36
Selection.InsertFile FileName:= Format(i,"00")
Next

End Sub

keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
Back
Top