Setting up Editing Restrictions in Word

C

Cyril Mathey

Hello,

I am trying to specify a protection policy for a document using the Word
object model.

To globally enable/disable protection I use Word.Document.[Un]Protect and it
works fine.

Now I need to specify some ranges that the user can edit (somewhat like what
is available in the "Protect Document" task pane within word).

I have found nothing so far on MSDN or with Intellisense (there is a
Word.Range.CanEdit property, but it is readonly).

Does someone know how to do this ?

Thanks a lot
 
J

Jonathan West

Hi Cyril

If you insert section breaks within your document, you can protect
individual sections.

Beware though that you should think of this as a way of making it easier for
people to do the right thing when editing, and not to make it impossible for
them to do the wrong thing. Even if you apply protection with a password, it
can be circumvented by inserting the protected document into a blank
inprotexted document, using the Insert File command.


--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
 
C

Cyril Mathey

Hello Jonathan,

First, thanks for the reply
Hi Cyril

If you insert section breaks within your document, you can protect
individual sections.

This sounds a bit overkill to me. What I would like is to protect the whole
document, while still keeping some editable ranges. I don't want to change
the structure of the document.
Beware though that you should think of this as a way of making it easier for
people to do the right thing when editing, and not to make it impossible for
them to do the wrong thing.

This is exactly what I am trying to do. As a matter of fact, I am building a
smart document solution. When the XML expansion pack is loaded for a
document, it should protect part of this document and only allow editing the
protected fragments through contextual actions in the Task Pane. This is
really the typical use case of smart documents, so I really wonder whether I
have overlooked something in the -slim- documentation on in the technical
articles that I have read. After all, it should be a pretty basic feature to
implement (?)
Even if you apply protection with a password, it
can be circumvented by inserting the protected document into a blank
inprotexted document, using the Insert File command.

Thanks.
I have posted this article in microsoft.public.office.developer.smarttag.
Maybe someone there has already implemented something like this.

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com



Cyril Mathey said:
Hello,

I am trying to specify a protection policy for a document using the Word
object model.

To globally enable/disable protection I use Word.Document.[Un]Protect
and
 
C

Cindy Meister -WordMVP-

Hi Cyril,

It always helps if you mention the version of Word for which you're
programming. In this case it makes all the world of difference: take a look at
the options you're offered under Tools/Protect document for Word 2003.
This is exactly what I am trying to do. As a matter of fact, I am building a
smart document solution. When the XML expansion pack is loaded for a
document, it should protect part of this document and only allow editing the
protected fragments through contextual actions in the Task Pane. This is
really the typical use case of smart documents, so I really wonder whether I
have overlooked something in the -slim- documentation on in the technical
articles that I have read. After all, it should be a pretty basic feature to
implement (?)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

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

Cindy Meister -WordMVP-

Replied to duplicate question in the
office.developer.automation group.

Cindy Meister
 
C

Cyril Mathey

Cindy,
Hi Cyril,

It always helps if you mention the version of Word for which you're
programming.

Yes, you're right.
I am using Office 2003 RTM.
In this case it makes all the world of difference: take a look at
the options you're offered under Tools/Protect document for Word 2003.

Yes, I am aware of that. This was what I was referring to when I wrote
"somewhat like what
is available in the "Protect Document" task pane within word".

What I am looking for is to do the same thing through the Word Object Model
in .NET (e.g. using the Word 2003 PIA and C#).


Thanks
 
C

Cindy Meister -WordMVP-

Hi Cyril,
Yes, I am aware of that. This was what I was referring to when I wrote
"somewhat like what
is available in the "Protect Document" task pane within word".
But someone not yet familiar with Word 2003 won't realize this :)
What I am looking for is to do the same thing through the Word Object Model
in .NET (e.g. using the Word 2003 PIA and C#).
Have you tried recording a macro in Word to get the basic syntax? That's
always the best way to get an idea of where to start looking in the object
model of an Office application (Word, Excel). That gives me things like

Selection.Editors.Add wdEditorEveryone
ActiveDocument.Protect Password:="", NoReset:=False, Type:= _
wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False

I believe Editor and Editors is where you want to start in the Word object
model Help files. But there isn't a lot of info in there, so the macro
recorder is going to be important for this.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

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

Cyril Mathey

Hello Cindy,
Hi Cyril,

But someone not yet familiar with Word 2003 won't realize this :)

Have you tried recording a macro in Word to get the basic syntax? That's
always the best way to get an idea of where to start looking in the object
model of an Office application (Word, Excel). That gives me things like

Selection.Editors.Add wdEditorEveryone
ActiveDocument.Protect Password:="", NoReset:=False, Type:= _
wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False

I had this part right :) I was stuck with the individual restriction
settings.
I believe Editor and Editors is where you want to start in the Word object
model Help files. But there isn't a lot of info in there, so the macro
recorder is going to be important for this.

I've just tried this Macro Recorder trick and it is great !

You are correct, the solution is indeed to use Selection.Editors.Add. It
works just fine.

Thanks a lot for your help.
 
C

Cindy Meister -WordMVP-

Hi Cyril,
I've just tried this Macro Recorder trick and it is great !

You are correct, the solution is indeed to use Selection.Editors.Add. It
works just fine.

Thanks a lot for your help.
You're most welcome :) I only had the chance to fool around a very little
bit with the XML tags and protection, so I'd be curious to find out if it
allows you to do everything you like, or if you run into any snags with
the combination?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

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