Cannot enter table caption text in Word protected document

Posted on 2016-08-31
Last Modified: 2016-09-01
Designed a protected document in Word with sections that everyone can edit.  Other sections are locked/protected.

Working in the unprotected sections, the user can enter anything, including a table or figure.  But, when the user tries to enter a caption, the Caption message box will not allow user to make content entry in the "Caption" field.  The caption field does get populated with the correct section number and table number, i.e. "10-1", but the user cannot add anything further.  An error message asserts saying "This is not a valid selection."  If I unprotect the entire document, no troubles entering user content into the caption field via the message box.

Oh...another thing.  if the user just accepts the caption label provided, e.g. Table 10-1, and selects OK on the message box, the caption is appropriately placed in the document - which if fine.  At this point, further text can be added to the caption.

I'm guessing it has something to do with that the caption label contains hidden bookmarks.  

I have other macros that I have written to temporarily unlock and then relock the document.  Is there a way to do this for this problem?
Question by:Roger Hardy
  • 3
  • 3
LVL 76

Expert Comment

ID: 41778559
It will save asking  many questions if you could post a sample document (redacted if necessary).

Some of the questions are:

What sort of protection?
By section, do you mean a Word document Section, or just block of text?
What type of field is the caption field?

Author Comment

by:Roger Hardy
ID: 41778624
Protection code:

 'select the two document Sections for Process Owners to edit
 With ActiveDocument
     Selection.Editors.Add wdEditorEveryone
     Selection.Editors.Add wdEditorEveryone
 End With

 'protect the rest of the document
 ActiveDocument.Protect Password:="XXXXX", NoReset:=False, Type:=wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=True

Author Comment

by:Roger Hardy
ID: 41778626
The Caption is not a field.  Its from "Insert Caption" option on the menu of options found by right clicking on the crossed arrow icon that appears near the top left corner of a selected table.

The table is not in the protected portion of the document.
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

LVL 76

Expert Comment

ID: 41779694
OK, Gottit now.

I can reproduce the problem (in Word 2007), so I suppose that it is a bug. However Word 2003 works properly.

In view of the fact that the cursor is automatically placed after the SEQ field just where the typed-in text would go, It might not be worth the creating a special macro.

The method would probably involve the macro having  the same name as the Word command that opens the dialogue, This would run instead of the Word command. In it, the code would turn off protection, display the dialogue and restore the protection after the dialogue is dismissed.

It would take some research to determine the correct command and dialogue.
LVL 76

Accepted Solution

GrahamSkan earned 500 total points
ID: 41779956
The code itself turns out to be quite simple:
Sub InsertCaption()
    Dim dlg As Word.Dialog

    With ActiveDocument
        If .ProtectionType = wdAllowOnlyReading Then
            .Unprotect ', password
        End If
        Set dlg = Application.Dialogs(wdDialogInsertCaption)
        .Protect wdAllowOnlyReading, True ',password
    End With
End Sub

Open in new window


Author Closing Comment

by:Roger Hardy
ID: 41780015
That worked.  Thank you!

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB6 ListBox Question 4 48
Deleting Unselectable Lines in Word 2013 2 73
Word Perfect Question 11 25
VBA to find and replace multiline text from VBA modules 8 64
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question