J
Jocke
1. I am opening Word through Excel (No problem)
2. Adding a new document in Word (No problem)
3. Trying to insert Wordfiles stored on disc into new created document by:
oDoc.Selection.InsertFile FileName:=MyFile, Link:=False
The program does not accept the line above. Why?
Here is the total program:
Sub InsertWordFiles()
'Inserts all Wordfiles in "C:\Temp" into a new created Worddocument
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim MyFile As String
'Open Word and add a new document
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
oWord.Activate
Set oDoc = oWord.Documents.Add
'Add all Wordfiles in "C\Temp" into new created Wordfile
ChDir "C:\Temp"
MyFile = Dir("*.doc")
Do
oDoc.Selection.InsertFile FileName:=MyFile, Link:=False
MyFile = Dir
Loop Until MyFile = Empty
End Sub
2. Adding a new document in Word (No problem)
3. Trying to insert Wordfiles stored on disc into new created document by:
oDoc.Selection.InsertFile FileName:=MyFile, Link:=False
The program does not accept the line above. Why?
Here is the total program:
Sub InsertWordFiles()
'Inserts all Wordfiles in "C:\Temp" into a new created Worddocument
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim MyFile As String
'Open Word and add a new document
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
oWord.Activate
Set oDoc = oWord.Documents.Add
'Add all Wordfiles in "C\Temp" into new created Wordfile
ChDir "C:\Temp"
MyFile = Dir("*.doc")
Do
oDoc.Selection.InsertFile FileName:=MyFile, Link:=False
MyFile = Dir
Loop Until MyFile = Empty
End Sub