CPGDeveloper
Board Regular
- Joined
- Oct 8, 2008
- Messages
- 189
I'm having a hell of time with this -- I'm sure it's something simlple I'm missing -- but from an Access application, I'm trying to combine up to 4 word docs into one word doc, and then convert it into a pdf.
I thought I would simply copy and paste each word doc one by one into a new doc, and then save the new doc as a pdf.
I create the word application and open a new document:
Set objWord = CreateObject("Word.Application")
Set docbase = objWord.Documents.Add
docbase.SaveAs2 mypath & ".doc", 0
I then open the word doc I want to copy from, and try and copy and paste into my new document:
Set doc = objWord.Documents.Open(docflnm) 'docflnm is the document i want to copy from
doc.Activate
objWord.ActiveDocument.Range.WholeStory
objWord.ActiveDocument.Range.Select
objWord.ActiveDocument.Range.Copy
docbase.Activate
objWord.ActiveDocument.Characters.Last.Select
objWord.Selection.Collapse
objWord.ActiveDocument.Range.Paste
doc.Close
It copies and pastes, but it writes over whatever was there before -- so if I run this sequence through a loop of say 4 word documents, only the last one shows up in my new document.
Any ideas?
I thought I would simply copy and paste each word doc one by one into a new doc, and then save the new doc as a pdf.
I create the word application and open a new document:
Set objWord = CreateObject("Word.Application")
Set docbase = objWord.Documents.Add
docbase.SaveAs2 mypath & ".doc", 0
I then open the word doc I want to copy from, and try and copy and paste into my new document:
Set doc = objWord.Documents.Open(docflnm) 'docflnm is the document i want to copy from
doc.Activate
objWord.ActiveDocument.Range.WholeStory
objWord.ActiveDocument.Range.Select
objWord.ActiveDocument.Range.Copy
docbase.Activate
objWord.ActiveDocument.Characters.Last.Select
objWord.Selection.Collapse
objWord.ActiveDocument.Range.Paste
doc.Close
It copies and pastes, but it writes over whatever was there before -- so if I run this sequence through a loop of say 4 word documents, only the last one shows up in my new document.
Any ideas?