Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Tables / July 2004

Tip: Looking for answers? Try searching our database.

how to make a cell readonly

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alex - 08 Jul 2004 08:41 GMT
how to make a cell readonly
Jean-Guy Marcil - 08 Jul 2004 14:14 GMT
Bonjour,

Dans son message, < Alex > ?crivait :
In this message, < Alex > wrote:

|| how to make a cell readonly

Get Word 2003 or use Excel.
Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Alex - 08 Jul 2004 14:19 GMT
Got it, now what?
I want to do this programmatically.

> Bonjour,
>
[quoted text clipped - 4 lines]
>
> Get Word 2003 or use Excel.
Jean-Guy Marcil - 08 Jul 2004 14:54 GMT
Bonjour,

Dans son message, < Alex > ?crivait :
In this message, < Alex > wrote:

|| Got it, now what?
|| I want to do this programmatically.

I don't have my 2003 version installed at the moment, so I cannot look up
the new VBA objects related to that new feature.

I bet that if you used the macro recorder to protect a cell, and then look
at the code, that would be a great place to start.

Also, since you want to do this programmatically, you should post in the
vba.general or vba.beginners groups (Choose one, not in both!).

By the way, next time you post a question, I think it would be a good idea
to try to explain in a few more details what you want to do. Here is your
original post:

<quote>
how to make a cell readonly
<unquote>

You have to admit that it was not really clear that you wanted to do this
programmatically, or that you already knew how to do that manually, or that
you had Word 2003... Especially since the message was identical to the
subject line..

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Jay Freedman - 08 Jul 2004 16:15 GMT
> Bonjour,
>
[quoted text clipped - 25 lines]
> manually, or that you had Word 2003... Especially since the message
> was identical to the subject line..

The way the new protection feature is set up, you don't directly protect a
specific cell or other range. Instead, you assign "editors" who are allowed
to modify certain areas, and any area that doesn't have any editor will be
protected. Although you can specify individual people as editors by
supplying their email addresses, you probably want the Everyone group to be
able to edit the parts outside the protected cell.

As far as I can tell, it isn't possible to assign Everyone as the editor for
the whole document and then delete that editor for the specific cell to be
protected. You must assign the editor for each individual range that is not
the protected cell: the area before the table, the area after the table, all
rows in the table before the cell, all rows after the cell, and the cells in
the same row to the left and right of the protected cell.

The following macro is extremely simplified, as noted in the comment...

Sub ProtectCellOnly()
  ' Oversimplified example:
  ' Assume the document has one table, and you
  ' want to protect the cell in the second row,
  ' second column.
  ' Note: in a real environment you need error-
  ' checking to ensure there is a table and that
  ' it has a .Cell(2,2). The macro will also fail
  ' if the table contains any split cells or
  ' nested tables.

  Dim oRg As Range
  Dim oTbl As Table
  Dim oRow As Row
  Dim oCell As Cell

  Set oTbl = ActiveDocument.Tables(1)

  Set oRg = ActiveDocument.Range
  oRg.End = oTbl.Range.Start ' = doc range before table
  oRg.Editors.Add wdEditorEveryone

  Set oRg = ActiveDocument.Range
  oRg.Start = oTbl.Range.End ' = doc range after table
  oRg.Editors.Add wdEditorEveryone

  For Each oRow In oTbl.Rows
     If oRow.Index <> 2 Then
        oRow.Range.Editors.Add wdEditorEveryone
     Else
        For Each oCell In oRow.Cells
           If oCell.Column.Index <> 2 Then
              oCell.Range.Editors.Add wdEditorEveryone
           End If
        Next oCell
     End If
  Next oRow

  ActiveDocument.Protect Type:=wdAllowOnlyReading
End Sub

Signature

Regards,
Jay Freedman
Microsoft Word MVP          FAQ: http://word.mvps.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.