I'm trying to paste/consolidate 6 documents ( in a folder) into a new documents, containing all those documents. The VBA code is supposed to run from an Excel Template where all the documents are created and are then supposed to be merged together via a macros.
However, I get the
Run time Error 438: object doesn't support this property or method
every time I try to run the InsertFile
line. I guess the problem lies in the transition from Excel to Word VBA(?)
Any ideas or thoughts?
Sub MergeALL()
Dim objWord
Dim objDoc
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add
objWord.Visible = True
'opens a new word document
Documents.Add
Dir "\\rz_sixt\user\Home\Pictures" 'change to OutputFilePath ?
MyName = Dir("*.docx")
While MyName <> ""
With Selection
.InsertFile Filename:=MyName, ConfirmConversions:=False, Link:=False, Attachment:=False
.InsertParagraphAfter
.InsertBreak Type:=wdSectionBreakNextPage
.Collapse Direction:=wdCollapseEnd
End With
MyName = Dir()
Wend
End Sub