Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-09-2022, 04:25 PM
slmaples slmaples is offline Mingle legacy fields and content controls so external program can insert data at bookmarks Windows 11 Mingle legacy fields and content controls so external program can insert data at bookmarks Office 2016
Novice
Mingle legacy fields and content controls so external program can insert data at bookmarks
 
Join Date: Feb 2022
Posts: 6
slmaples is on a distinguished road
Default Mingle legacy fields and content controls so external program can insert data at bookmarks

A client management db passes information to my Word forms by way of Bookmarks thus all forms use legacy fields with approved identifiers in the 'Bookmark' property.

Now I need functionality that the legacy fields don't offer. Can I intermingle these older fields with content controls in the same form. Will tabbing work correctly?

If not, can I somehow link a bookmark to a content control?
Reply With Quote
  #2  
Old 02-09-2022, 06:52 PM
Guessed's Avatar
Guessed Guessed is offline Mingle legacy fields and content controls so external program can insert data at bookmarks Windows 10 Mingle legacy fields and content controls so external program can insert data at bookmarks Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

In very brief testing, it appears that the form fields are skipped over when there are CCs in the file. I've seen mvps and admins on this and other forums vaguely advise against intermingling CCs and legacy fields so that may be the reason that advise is provided. I have not yet seen other problems when this happens but if it can be avoided I would say you should stick with one or the other.

The method the Client Mgmt DB uses to populate the bookmarks is an unknown factor so if you can't manipulate it and it is critical to the document usage then I would probably stay exclusively with legacy fields. Or else you lose the 'tab into fields' functionality.

You could conceivably use bookmarks inside a rich text CC but the bookmark would likely be destroyed if someone tabs into the CC and types. Conversely, putting the bookmark outside the CC would remove the CC when the DB updates the bookmark value. Either way there is a drawback that you should avoid if the DB is updating content as well as allowing users to tab across fields and possibly retype content.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 02-09-2022, 10:20 PM
gmayor's Avatar
gmayor gmayor is offline Mingle legacy fields and content controls so external program can insert data at bookmarks Windows 10 Mingle legacy fields and content controls so external program can insert data at bookmarks Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,106
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 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
  #4  
Old 02-10-2022, 10:28 AM
slmaples slmaples is offline Mingle legacy fields and content controls so external program can insert data at bookmarks Windows 11 Mingle legacy fields and content controls so external program can insert data at bookmarks Office 2016
Novice
Mingle legacy fields and content controls so external program can insert data at bookmarks
 
Join Date: Feb 2022
Posts: 6
slmaples is on a distinguished road
Default

Thank you, GMayor. If I understand your macro 1 correctly, your naming the bookmark with the title of the control. Since my external source is looking for specific bookmark names then I would Title the control with those specific keywords. Yes?
Reply With Quote
  #5  
Old 02-10-2022, 10:18 PM
gmayor's Avatar
gmayor gmayor is offline Mingle legacy fields and content controls so external program can insert data at bookmarks Windows 10 Mingle legacy fields and content controls so external program can insert data at bookmarks Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,106
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 of
Default

If you use the add-in to convert form fields to content controls, the content controls will be titled with the bookmark names from the form fields. The add-in will allow you to page through the controls and change any titles if required.
The macro simply adds the bookmarks to the content controls using the same names as the content control titles. Content controls are not otherwise bookmarked and thus would not be seen by your external source.
__________________
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
  #6  
Old 02-17-2022, 10:00 AM
slmaples slmaples is offline Mingle legacy fields and content controls so external program can insert data at bookmarks Windows 11 Mingle legacy fields and content controls so external program can insert data at bookmarks Office 2016
Novice
Mingle legacy fields and content controls so external program can insert data at bookmarks
 
Join Date: Feb 2022
Posts: 6
slmaples is on a distinguished road
Default

Thank for all of this but it seems my external source cannot pass data to the bookmarked content control. Bummer.

That said, I can pass data to hidden text fields in the document. Could I, with code, write the value of a hidden filed to a content control?
Reply With Quote
  #7  
Old 02-17-2022, 10:11 AM
Charles Kenyon Charles Kenyon is offline Mingle legacy fields and content controls so external program can insert data at bookmarks Windows 10 Mingle legacy fields and content controls so external program can insert data at bookmarks Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Legacy form fields are not required for there to be bookmarks.
You can add bookmarks to your document/template and these can be written to by an application.
Reply With Quote
  #8  
Old 02-17-2022, 10:36 AM
slmaples slmaples is offline Mingle legacy fields and content controls so external program can insert data at bookmarks Windows 11 Mingle legacy fields and content controls so external program can insert data at bookmarks Office 2016
Novice
Mingle legacy fields and content controls so external program can insert data at bookmarks
 
Join Date: Feb 2022
Posts: 6
slmaples is on a distinguished road
Default

Charles, It seems that would simply things. I'm testing and I don't see the data expected in the bookmark I added. I do see data in the Text form fields (legacy). Maybe I don't understand the technique.
Reply With Quote
  #9  
Old 02-17-2022, 11:06 AM
Charles Kenyon Charles Kenyon is offline Mingle legacy fields and content controls so external program can insert data at bookmarks Windows 10 Mingle legacy fields and content controls so external program can insert data at bookmarks Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

It sounds as if you need to talk with your application developer. For some reason they are looking for legacy formfields and identifying them by their bookmarks rather than simply inserting at a bookmark.
Reply With Quote
  #10  
Old 02-17-2022, 11:18 AM
slmaples slmaples is offline Mingle legacy fields and content controls so external program can insert data at bookmarks Windows 11 Mingle legacy fields and content controls so external program can insert data at bookmarks Office 2016
Novice
Mingle legacy fields and content controls so external program can insert data at bookmarks
 
Join Date: Feb 2022
Posts: 6
slmaples is on a distinguished road
Default

I agree. I think they are looing for a field property instead of a bookmark. If that is true can I go back to idea of a hidden field? Could I write that value elsewhere?
Reply With Quote
  #11  
Old 02-17-2022, 12:13 PM
Charles Kenyon Charles Kenyon is offline Mingle legacy fields and content controls so external program can insert data at bookmarks Windows 10 Mingle legacy fields and content controls so external program can insert data at bookmarks Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

We do not have access to the code that is writing the data. You need to work with your application developers. They could write to:
  • A bookmark
  • A document variable
  • A document property
  • A content control
Instead, they are apparently writing to a legacy formfield with a given bookmark name. Unless their code is changed, that is where it will write.

A legacy formfield is not an ordinary Word field. (MS has a long practice of using confusing names.)

You could insert a legacy formfield with the bookmark and format it as hidden using the font formatting dialog. How that would work I have no idea.
Reply With Quote
Reply

Tags
control, legacy



Similar Threads
Thread Thread Starter Forum Replies Last Post
insert the 2 content controls into a Repeating Section in a table smaccharoli Word VBA 2 02-27-2018 08:49 AM
Mingle legacy fields and content controls so external program can insert data at bookmarks How to insert bookmarks for content or Text of ContentControl lvganesh Word VBA 5 12-12-2017 11:27 PM
How can I set up tab to go back and forth between legacy fields and content control fields in a Word Ikajed Word 1 10-13-2017 06:06 PM
Creating a Report Template / User Form and/or Content Controls with repetitive data throughout 53bigdog Word VBA 1 04-05-2016 04:00 PM
Insert image icons are showing up on images that have content controls but only on some computers. mandylach Word 0 11-10-2014 07:44 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:51 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft