Word vba - if cursor is in cell / bookmark - run code -


I have a template document that contains several sections and some tables are the thing, I have a drop inside cells in the table I'm trying to put a drop-down list. For a drop-down list to work, the document needs to be protected. But if I am protecting the entire volume, then the table is completely secure

So, I was wondering if there is a way to execute a macro code if the user clicks on the drop-down list is? The code will then protect the document, which actually controls, then select an option and when the user clicks outside the field, the document should be unsafe.

Is this possible?

In Word VBA you can actually use a windowSelectionChange event. This is described in the Word VBA Help file under "Using Event with Event Objects".

driver to assign a variable in the class module using public up Aevent app Aedents Aedvents Kvesd with Aedvends app Word your app (I My Event Class Module is named). Application

Then in your normal document Open event, you can initialize the current variables are:

  new phenomenon dim oEvents as private class modules set up document_Open () to oEvents.App = Word.Application End sub  

Back in EventClassModule, you select window for selection if the selection table:

  Private sub-app_WindowSelectionChange (Val Cells as Selection) If Sel.Information (wdWithInTable) and this document Security type = wdNoProtection then this Document.Protect wdAllowOnlyFormFields ElseIfThisDocument.ProtectionType & lt; & Gt; WdNoProtection then this document. If the cursor changes the location, the code will be terminated if the ending sub  

changes the location. I tested it and it is a bit nicer (the object object is the tendency to be undefined for some reason), but hopefully this will be the beginning of your solution.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -