Retrieve text of Word Doc from protected document?

L

lotus

It works good on unprotected document that retrieve text from Word
document by calling Range.GetText(), however, it throws an exception on
a protected document. Are there any other methods for this case? Any
cues are appreciated.
 
C

Cindy M -WordMVP-

Hi Lotus,
It works good on unprotected document that retrieve text from Word
document by calling Range.GetText(), however, it throws an exception on
a protected document. Are there any other methods for this case?
You would need to unprotect the document, get the text, then reprotect
the document without resetting the field content. Roughly, in VBA:
If doc.ProtectionType <> wdNoProtection Then
doc.Unprotect
End If
s = doc.Content.GetText()
doc.Protect Type:=wdAllowOnlyformFields, NoReset:=True

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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