vbscript >> vbscript example needed, how to extract and insert content into word documents

by joes » Thu, 18 Nov 2004 07:15:23 GMT

Hello there

I like to update dynamically some word doucments. Therefore I like to
extract some specific content from a word document and to paste it
into others at a given place. I think this should be possible in
VBScript? I am using Word XP
In order to get a good starting point, I need some some answers to my
questions below. You can post me also some links to good tutorials,
articles or even books.

- Where do I find resources about the word document model? I did a
quick debbuging inside the visual basic edotor of word, but the
ActiveDocument.Content object has a lot of properties. The help does
not provide therefore enough suport.

- How to step through the content of the word document with VBScript?

- How should I mark inside my document special sections (start, end)
so that I am able to find it with my VBScript?

- How can I copy a section from a document and paste it into another
with VBScript? What will happen to styles, will those also be copied?

Thank you

Best regards

Similar Threads

1. Inserting content control in Word 2007 Footer using Word PIA in C#

Hi All,

I programmatically insert a plain text content control in a footer with 
below code.

Microsoft.Office.Interop.Word.Document wordDocument = 
application.Documents.Open( ref fileName, ref objFalse, ref objReadOnly, ref 
objFalse, ref objMissing,
                                               ref objMissing, ref objFalse, 
ref objMissing, ref objMissing, ref objMissing,
                                               ref objMissing, ref 
ObjVisible, ref objFalse, ref objMissing, ref objTrue,
                                               ref objMissing ) as 

//cursor is focused some where in Footer before I call this code.
object range = wordDocument.ActiveWindow.Selection.Range;
ContentControl cc = 
ref range);
cc.Tag = "myContentControl"

Here wordDocument.ContentControls.Add() returns a content control without 
adding it to the wordDocument.ContentControls collection.
The wordDocument.ContentControls.Count remains same before and after.

Strangely, I could see the same conten control in the collection with the 
following code:

ContentControls ccs = 

As I need to iterate wordDocument.ContentControls in different parts of my 
application for all content controls (without bothering about tag)in the 

Could you please suggest me how I can add it(CC in footer) to 
wordDocument.ContentControls or a collection where I can retrieve it later.

Thank in Advance,
ps: I have same problem inserting a content control in a Text Field.

2. Inserting content control in Word 2007 Footer using Word PIA i - Word VBA

3. Word 2007 - automatically populate document property using document contents


I am a teacher & have to create a standard layout lesson plan for my
management's occasional perusal.

I'd like the box (cell in a Word 2007 table) which they have called
"Keywords" to automatically populate that document's tag (the metadata
that is visible in Explorer and is made available to Vista's search
via "tag:pythagoras")

Can anyone help? I assume I need to set that box to be a field, but
then how to write the file's metadata, and how to capture multiple
values into multiple tag values.

pythagoras; geometry ; proof

I'm in Word 2007 and about 5 years ago was a reasonable coder in VBA
for Excel 2003 if that's any use at all!

Cheers Rob 

4. Word VBA Copying Document Content from other documents issue - Word VBA

5. Extract word document content and save in MS Access


i need VBA code - Extract word document content and save in MS Access.

Raju A

6. insert file in word document using vbscript - Scripting for Windows Server

7. How to extract content from other word documents

Hi All,
                 I have a large number of word documents with me and each 
document contains  section called introduction or overview (header 1) (it is 
either one of the two). I would like to consolidate all of this into a new 
word document. How do I do the same

In short take (overview/intro) sections from different document and dump it 
into a single word file.

Here are my computer details

OS: Windows XP
Office 2003 Professional


8. NEW USER needs to extract name and insert in letter after 'Dear'