macro for readonly attribute to a table cell

A

azam baig

Hi,

how can i set readonly property to a cell of a table in the wor
document

means like user should not be able to edit the cell
can you please send me the macro code.

your help will be highly appreciated.
its very urgent.

Thanks in Advanc
 
D

Doug Robbins - Word MVP

You cannot set such a property for a cell in a Word table. All that you can
do is protect the document.

You can probably do what you want however if you insert an Excel Spreadsheet
into the document in place of a Word table. When not being actually edited,
it will appear the same.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
A

azam baig

Thank you Robbins

could you please provide me the macro code for protecting the document
and making the cell uneditabl
 
D

Doug Robbins - Word MVP

ActiveDocument.Protect wdAllowOnlyFormFields

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
A

azam baig

Thanks again Robin

but here my problem is
i have placed the following code
ACTIVEDOCUMENT.PROTECT WDALLOWONLYFORMFIELDS[/B]
IN THE FOLLOWING EVENT
OAPP_WINDOWSELECTIONCHANGE(BYVAL SEL AS SELECTION)
WHEN I SINGLE CLICK ON THE CELL THE ABOVE EVENT FIRES AND THE CURSOR IS
GOING TO TOP OF THE TABLE.BUT ACTUALLY MY REQUIREMENT IS WHEN I CLICK ON
THE CELL THAT PARTICULAR CELL SHOULD BECOME READONLY AND SHOULD NOT BE
EDITABLE
AND I HAVE ANOTHER EVENT CALLED
OAPP_WINDOWBEFOREDOUBLECLICK(BYVAL SEL AS SELECTION, CANCEL AS BOOLEAN)
WHEN I DOUBLE CLICK ON THE CELL I AM SHOWING THE INPUTTEXTBOX AND ONCE
WE TYPE ANY DATA IN THE INPUTBOX AND CLICK OK THEN THAT DATA WILL BE
INSERTED IN THE CORRESPONDING CELL.

SO WHEN I DOUBLE CLICK THE CELL NOTHING IS HAPPENING NOW AFTER I PLACED
THIS CODE(ACTIVEDOCUMENT.PROTECT WDALLOWONLYFORMFIELDS).

THE FOLLOWING IS THE CODE I HAVE WRITTEN FOR SINGLE CLICK AND DOUBLE
CLICK OF A CELL
PRIVATE SUB OAPP_WINDOWSELECTIONCHANGE(BYVAL SEL AS SELECTION)
ACTIVEDOCUMENT.PROTECT WDALLOWONLYFORMFIELDS
END SUB

PRIVATE SUB OAPP_WINDOWBEFOREDOUBLECLICK(BYVAL SEL AS SELECTION, CANCEL
AS BOOLEAN)

IF SELECTION.INFORMATION(WDWITHINTABLE) THEN
DIM I AS VARIANT
DIM STR AS STRING
I = INPUTBOX(\"ENTER THE TEXT\", \"CELLCLICK\")
SELECTION.TEXT = I
CALL ISLASTCELL
END IF

END SUB
could you please come up with any solution.

your help will be highly appreciated.

Thanks in advance.
 
D

Doug Robbins - Word MVP

How about you telling us exactly what it is that you want to achieve. Not
just protecting a single cell, which is not really possible in Word, but
overall, what is the application.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
A

azam baig

ok,Robbin

i have word document

and it contains tables

each table will have data in the table cells

here our clients requirement is

if anyone wants to edit the table cell data,it should not allow to edi
it and for that i need to write the code in *oApp_WindowSelectionChange
event.
but iam not sure of what code to write in that event to restrict th
user for editing the data of the table cell.
And
when he double clicks on the cell he wants to get one inputbox to ente
the data and once he says ok that data should be placed in th
corresponding cell where he double clicks.

is this information sufficient to you.

Thanks for showing interest

waiting for your repl
 
C

Cindy M.

Hi Azam,

Is the user allowed to edit anything at all in the document?

Which version of Word are you targeting?
i have word document

and it contains tables

each table will have data in the table cells

here our clients requirement is

if anyone wants to edit the table cell data,it should not allow to edit
it and for that i need to write the code in *oApp_WindowSelectionChange*
event.
but iam not sure of what code to write in that event to restrict the
user for editing the data of the table cell.
And
when he double clicks on the cell he wants to get one inputbox to enter
the data and once he says ok that data should be placed in the
corresponding cell where he double clicks.


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 :)
 

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