VB Text/Formatting extraction from Word XP

T

theWatcher

Hello -

I am writing a VB6 app that opens a Word document (Word XP) and populates the
pre-existing Doc Variables with data from a database. The user is then able to
edit the text and/or formatting (italics, superscript, bold, etc.) of these
fields. Once the changes have been made, the VB app needs to extract the
modified data from the specific fields (text and/or formatting), analyze it, and
store it in the database so that the exact document may be reproduced at a later
date. The questions I have are:

1. How do I extract the modified data from the doc variable fields? The
Variables("varname").Value property only contains the data I originally sent to
it and seems not to be dynamically linked to the field on the document. The
closest I have come is to use the Fields(x).Select and Selection.Text
combination, but I'd rather have access to the named variables, since
Fields(1,2,3...) may not refer to the same information in every document.

2. How do I identify formatting changes in a specific field? If the user
simply changes normal text to italicized, I need to capture that change as well.

3. How do I extract formatting codes from Word so that the formatted text can
be preserved in a database for future reproduction? How do I read that
formatted data into Word later to reproduce the exact document? (Is this
HTML-type formatting?)

4. How do I interrupt or Cancel the Close event in Word? I do not want for the
user to be able to close the document before the app has a chance to process the
data, so I have hidden all of the Close/Save functions in the File menu, but the
Close button (X) at the top, right of the screen still exists. I want to cancel
the close event (similar to Canceling the FormUnload event for VB forms), but
have been unable to find one for Word.

Thank you for any help you can provide.
 
J

Jonathan West

Answered in the userforms group. Please do not post multiple copes of the
same message into different groups.
 
W

Word Heretic

G'day "theWatcher" <[email protected]>,

1) Use FormFields to hold data

2) take th para mark at the end and store the whole formatted range

3) read and export as ASCII RTF

4) Word 2k+

ThisDocument > Document_Close event.




Hello -

I am writing a VB6 app that opens a Word document (Word XP) and populates the
pre-existing Doc Variables with data from a database. The user is then able to
edit the text and/or formatting (italics, superscript, bold, etc.) of these
fields. Once the changes have been made, the VB app needs to extract the
modified data from the specific fields (text and/or formatting), analyze it, and
store it in the database so that the exact document may be reproduced at a later
date. The questions I have are:

1. How do I extract the modified data from the doc variable fields? The
Variables("varname").Value property only contains the data I originally sent to
it and seems not to be dynamically linked to the field on the document. The
closest I have come is to use the Fields(x).Select and Selection.Text
combination, but I'd rather have access to the named variables, since
Fields(1,2,3...) may not refer to the same information in every document.

2. How do I identify formatting changes in a specific field? If the user
simply changes normal text to italicized, I need to capture that change as well.

3. How do I extract formatting codes from Word so that the formatted text can
be preserved in a database for future reproduction? How do I read that
formatted data into Word later to reproduce the exact document? (Is this
HTML-type formatting?)

4. How do I interrupt or Cancel the Close event in Word? I do not want for the
user to be able to close the document before the app has a chance to process the
data, so I have hidden all of the Close/Save functions in the File menu, but the
Close button (X) at the top, right of the screen still exists. I want to cancel
the close event (similar to Canceling the FormUnload event for VB forms), but
have been unable to find one for Word.

Thank you for any help you can provide.

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top