A
Adam
Hello,
I'm "attempting" to make some code to insert different file types into a word doc then save it.
I have a folder that contains many .txt, .tif, .doc and .xls files.
I have been using the following (strFolderName being the user selected folder with the files ):-
Private Sub Document_Open()
Dim strFolderName As String
strFolderName = BrowseFolder("Select the folder you files are in?") & "\"
ChangeFileOpenDirectory strFolderName
Selection.InsertFile FileName:="textdoc.txt", Range:="", ConfirmConversions:=False, link:=False, attachment:=False
Selection.InlineShapes.AddPicture FileName:=strFolderName & "picture.tif", linktofile:=False, SaveWithDocument:=True
Selection.InsertFile FileName:=strFolderName & "word.doc", Range:="", ConfirmConversions:=False _
, link:=False, attachment:=False
Selection.InlineShapes.AddOLEObject ClassType:="Excel.sheet.8", FileName:=strFolderName _
& "excel.xls", linktofile:=False, DisplayAsIcon:=False
Selection.InlineShapes.AddOLEObject ClassType:="Excel.sheet.8", FileName:=strFolderName _
& "otherdoc.xls", linktofile:=False, DisplayAsIcon:=False
Selection.InlineShapes.AddOLEObject ClassType:="Excel.sheet.8", FileName:=strFolderName _
& "another.xls", linktofile:=False, DisplayAsIcon:=False
Activedocument.Saveas Filename:="NEWDOC.doc", FileFormat:=wdFormatDocument _
, LockComments:=false, password:=""
End Sub
However, does anyone know some code I can use if I don't know the names of the files, and to automatically add all the files from the directory, in the order of txt files, tif files, doc files then xls files.
Thanks in advance for any help.
I'm "attempting" to make some code to insert different file types into a word doc then save it.
I have a folder that contains many .txt, .tif, .doc and .xls files.
I have been using the following (strFolderName being the user selected folder with the files ):-
Private Sub Document_Open()
Dim strFolderName As String
strFolderName = BrowseFolder("Select the folder you files are in?") & "\"
ChangeFileOpenDirectory strFolderName
Selection.InsertFile FileName:="textdoc.txt", Range:="", ConfirmConversions:=False, link:=False, attachment:=False
Selection.InlineShapes.AddPicture FileName:=strFolderName & "picture.tif", linktofile:=False, SaveWithDocument:=True
Selection.InsertFile FileName:=strFolderName & "word.doc", Range:="", ConfirmConversions:=False _
, link:=False, attachment:=False
Selection.InlineShapes.AddOLEObject ClassType:="Excel.sheet.8", FileName:=strFolderName _
& "excel.xls", linktofile:=False, DisplayAsIcon:=False
Selection.InlineShapes.AddOLEObject ClassType:="Excel.sheet.8", FileName:=strFolderName _
& "otherdoc.xls", linktofile:=False, DisplayAsIcon:=False
Selection.InlineShapes.AddOLEObject ClassType:="Excel.sheet.8", FileName:=strFolderName _
& "another.xls", linktofile:=False, DisplayAsIcon:=False
Activedocument.Saveas Filename:="NEWDOC.doc", FileFormat:=wdFormatDocument _
, LockComments:=false, password:=""
End Sub
However, does anyone know some code I can use if I don't know the names of the files, and to automatically add all the files from the directory, in the order of txt files, tif files, doc files then xls files.
Thanks in advance for any help.