Retrieve text from a Protected Word Document

T

tartancli

An archived post to this forum (http://www.ureader.com/message/2849995.aspx)
indicated that, when a document is protected, attempts to read text
programmatically by getting the "content" range and then getting its text,
result in an exception being raised.

I would like to use this "feature" (ie. stop other Add-ins and VBA from
retrieving my document's text), but it does not seem to work for me. In Word
2003, i have tried protecting the document and then using doc.content.text to
retrieve the document text. I can retrieve the text both in the add-in itself
(immediately after protecting the doc) and in VBA macro. Is this "feature"
Word version dependant, or have i not protected the document properly? The
code that i use to protect is as follows:

// Apply Words own protection mechanism
void ProtectContent( Word.Document doc)
{

object missing = System.Reflection.Missing.Value;
object protPass = "the password";

doc.Protect( Word.WdProtectionType.wdAllowOnlyFormFields, ref
missing,ref protPass, ref missing, ref missing );
} // end ProtectContent

If it is not possible to protect document text from being read
programatically using the document protection mechanism, is there some other
way to do this.

Thanks in advance!
 
C

Cindy M.

Hi =?Utf-8?B?dGFydGFuY2xp?=,
An archived post to this forum (http://www.ureader.com/message/2849995.aspx)
indicated that, when a document is protected, attempts to read text
programmatically by getting the "content" range and then getting its text,
result in an exception being raised.
That was only in response to that particular situation. The method the person
was using - GetText() - is not part of the Word object model. No idea where it
was coming from...

As far as I know, there is no way to programmatically prevent anyone from
getting at the text of a Word document. Perhaps IRM (Information Rights
Management) has some option for this. But in a general way, no Office document
can be "secured". They simply weren't designed with this in mind.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
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 :)
 
T

tartancli

Thanks Cindy, most helpful as usual.

Cindy M. said:
Hi =?Utf-8?B?dGFydGFuY2xp?=,

That was only in response to that particular situation. The method the person
was using - GetText() - is not part of the Word object model. No idea where it
was coming from...

As far as I know, there is no way to programmatically prevent anyone from
getting at the text of a Word document. Perhaps IRM (Information Rights
Management) has some option for this. But in a general way, no Office document
can be "secured". They simply weren't designed with this in mind.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)


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