VB.net Word how to select the entire document to copy and paste into another document

  • Thread starter Thread starter dd8
  • Start date Start date
D

dd8

Guest
Ive inherited the following code and need to amend and add new code.



Once the details are completed writing in the word document.

Select the whole document and copy

switch to a different word document, goto the end of the document and paste

then switch back to the original document and repeat (reiterate) until all documents are done.



Any ideas

TIA



' create new certificate summary
Dim newDoc As Microsoft.Office.Interop.Word.Document = objWordApp.Documents.Add(Application.StartupPath & "\Templates\Certificate Summary.docx")

' create new certificate
Dim objDoc As Microsoft.Office.Interop.Word.Document = objWordApp.Documents.Add(Application.StartupPath & "\Templates\Certificate.docx")

objDoc = objWordApp.ActiveDocument
objDoc.Content.Find.Execute(FindText:="%NAME%", ReplaceWith:="" & dgImportedData.Item("dgName", i).Value.ToString.ToUpper & "", Replace:=Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll)
objDoc.Content.Find.Execute(FindText:="%COURSENAME%", ReplaceWith:="" & dgImportedData.Item("dgCourseName", i).Value & "", Replace:=Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll)
objDoc.Content.Find.Execute(FindText:="%ENDDATE%", ReplaceWith:="" & Format(CDate(dgImportedData.Item("dgCompletedDate", i).Value.ToString), "d MMMM yyyy") & "", Replace:=Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll)
objDoc.Content.Find.Execute(FindText:="%INSTRUCTOR%", ReplaceWith:="" & objDTInstructor.Rows(Params(2)).Item("FullName") & " " & objDTInstructor.Rows(Params(2)).Item("RegisteredNo"), Replace:=Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll)

' goto certificate summary doc at end
‘ and paste all certificate contents

Continue reading...
 
Back
Top