From: Modeerf60 on 9 Jan 2010 20:37 I am currently successfully moving data from Excel to Word and now want to use Excel VB to append several word files together (created from Excel 2003 on Windows XP Pro). I have two questions related to this. 1) I want to know how to move the insert point to the end of the Word document I open before I insert the next document. I recorded a macro in Word and then tried: WordApp.ActiveDocument.Selection.EndKey Unit:=6 But it didn't work. Does anyone know what will work? Please provide code examples. 2) I then want to insert a Word document at this end point. From that same Word macro, I learned and planned to use: WordApp.ActiveDocument.Selection.InsertFile Filename:="File1.doc" _ , Range:="", ConfirmConversions:=False, Link:=False, Attachment:=False will this work? If not what will work? Please provide code examples. Thanks M
From: macropod on 10 Jan 2010 20:09 Hi Modeerf60, Try something along the lines of: Dim oRng As Range With WordApp.ActiveDocument .Range.Characters.Last.InsertAfter vbCrLf Set oRng = .Range.Characters.Last oRng.InsertFile FileName:="File1.doc", ConfirmConversions:=False, Link:=False, Attachment:=False End With -- Cheers macropod [Microsoft MVP - Word] "Modeerf60" <Modeerf60(a)discussions.microsoft.com> wrote in message news:F3855060-74F0-4FF3-A420-BDD150925850(a)microsoft.com... >I am currently successfully moving data from Excel to Word and now want to > use Excel VB to append several word files together (created from Excel 2003 > on Windows XP Pro). I have two questions related to this. > > 1) I want to know how to move the insert point to the end of the Word > document I open before I insert the next document. I recorded a macro in Word > and then tried: > WordApp.ActiveDocument.Selection.EndKey Unit:=6 > But it didn't work. Does anyone know what will work? Please provide code > examples. > > 2) I then want to insert a Word document at this end point. From that same > Word macro, I learned and planned to use: > WordApp.ActiveDocument.Selection.InsertFile Filename:="File1.doc" _ > , Range:="", ConfirmConversions:=False, Link:=False, > Attachment:=False > will this work? If not what will work? Please provide code examples. > > Thanks > M >
|
Pages: 1 Prev: How to write networking code in VBA? Next: compare and arrange two sets of datta. |