tesseract
tesseract

Reputation: 901

Visual Basic Copying between word files

I have a template word document and want to copy a certain set of paragraphs and headings from the 1st word template to a new word document. I have bookmarked all the different sections in the template(added bookmarks in MS Word)

I have implemented all the check boxes and menu systems in visual basic. The check boxes decide which sections I want to copy from the template.but I don't know how to copy the text between the word files. can someone provide some information or a link

Am I on the right track with this https://msdn.microsoft.com/en-us/library/kw65a0we.aspx. but I could do with some help been stuck on this.

Upvotes: 1

Views: 1213

Answers (1)

Matt
Matt

Reputation: 547

You should be able to do this more easily by making a copy of the template document and then deleting the sections you don't want.

To save out a copy and use that (although using the template and then saving under another name should work as well):

File.Copy(template, copy)
objDoc = WordApp.Documents.Add(copy)

You can delete the contents of a bookmark with something like this:

objDoc.Range.Bookmarks(required).Range.Delete()

Upvotes: 1

Related Questions