View Single Post
 
Old 02-09-2022, 10:20 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

I wouldn't recommend using CCs and legacy form fields in the same document. They achieve the form functionality in different ways. Legacy form fields require the form to be protected for forms. CCs do not and as Andrew has suggested, do not provide the tabbed access when so protected.They provide that when Editors are applied and the document is protected as read only.

You can however bookmark the content control and you can lock the control against deletion. My CC Tools add-in Insert Content Control Add-In has a module to convert legacy form fields to rich text controls retaining the bookmark names (though the controls themselves are not bookmarked).

The bookmarking can be achieved easily enough with a simple macro. (Macro1 below). You can then use the option to add editors and protect the form. Test the outcome with Macro2. This will write the same value to all the controls. If you are happy with the result, you can clear the test values with macro3.

You will need the form password, if any, to convert form fields to content controls.

Frankly content controls are rather more robust than legacy form fields and if your third party application will work with them when bookrmarked (if it just writes to named bookmarks, it almost certainly should) that would be the way to go.

I suggest you experiment with a copy of the form.
Code:
Sub Macro1()
Dim oCC As ContentControl
    For Each oCC In ActiveDocument.ContentControls
        oCC.Range.Bookmarks.Add oCC.Title
    Next oCC
    Set oCC = Nothing
End Sub

Sub Macro2()
Dim i As Integer
Dim sName As String
Dim oBM As Bookmark
    For i = 1 To ActiveDocument.Bookmarks.Count
        sName = ActiveDocument.Bookmarks(i).Name
        FillBM sName, "This is a test"
    Next i
End Sub

Sub Macro3()
Dim oCC As ContentControl
    For Each oCC In ActiveDocument.ContentControls
        oCC.Range.Text = ""
    Next oCC
    Set oCC = Nothing
End Sub


Public Sub FillBM(strbmName As String, strValue As String)
'Graham Mayor - https://www.gmayor.com
Dim oRng As Range
    With ActiveDocument
        On Error GoTo lbl_Exit
        If .Bookmarks.Exists(strbmName) = True Then
            Set oRng = .Bookmarks(strbmName).Range
            oRng.Text = strValue
            oRng.Bookmarks.Add strbmName
        End If
    End With
lbl_Exit:
    Set oRng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote