wullie
11-10-2014, 09:40 AM
Hi,
As per snb's post in thread '37720-Merging-two-Word-documents-into-one-from-Excel', I have managed to get documents to combine, but the merging only copies the textual content of the files that I want to merge and not the tables in the templates.
Is there a way to do this that I am missing?
My code currently for the section I need is
Set wrdDoc = wrdApp.Documents.Open(objFolder & "\" & specialties(specialtyLoop) & "Combined.doc")
wrdApp.Visible = True
With wrdDoc
.Content.InsertAfter GetObject(objFolder & "\" & files(fileLoop)).Content
.SaveAs2 objFolder & "\" & specialties(specialtyLoop) & "Combined.doc", 12
.Close False
End With
I have also tried replacing the InsertAfter with '.Content.InsertFile Filename:=objFolder & "\" & files(fileLoop)', but that seems to overwrite rather than appending to the content.
Further to this, I have tried copy and pasting, which does copy the template as well, but pastes in place of the existing text (or visibly on top of when using OLEObject) and I can't seem to get it to escape off of the selection and to the bottom of the document.
Any help would be greatly appreciated.
Thanks
As per snb's post in thread '37720-Merging-two-Word-documents-into-one-from-Excel', I have managed to get documents to combine, but the merging only copies the textual content of the files that I want to merge and not the tables in the templates.
Is there a way to do this that I am missing?
My code currently for the section I need is
Set wrdDoc = wrdApp.Documents.Open(objFolder & "\" & specialties(specialtyLoop) & "Combined.doc")
wrdApp.Visible = True
With wrdDoc
.Content.InsertAfter GetObject(objFolder & "\" & files(fileLoop)).Content
.SaveAs2 objFolder & "\" & specialties(specialtyLoop) & "Combined.doc", 12
.Close False
End With
I have also tried replacing the InsertAfter with '.Content.InsertFile Filename:=objFolder & "\" & files(fileLoop)', but that seems to overwrite rather than appending to the content.
Further to this, I have tried copy and pasting, which does copy the template as well, but pastes in place of the existing text (or visibly on top of when using OLEObject) and I can't seem to get it to escape off of the selection and to the bottom of the document.
Any help would be greatly appreciated.
Thanks