Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-02-2022, 12:54 PM
Peterson Peterson is offline Binding Custom XML-Based Items to Content Control Dropdown Windows 10 Binding Custom XML-Based Items to Content Control Dropdown Office 2019
Competent Performer
Binding Custom XML-Based Items to Content Control Dropdown
 
Join Date: Jan 2017
Posts: 141
Peterson is on a distinguished road
Default Binding Custom XML-Based Items to Content Control Dropdown

Can you point me in the direction to learn how to bind multiple custom XML nodes to a drop-down content control?

I can see in custom XML from Word files that have been in a SharePoint document library with multi-selection list items that the drop-downs are functional in the Word file's doc properties. But the SharePoint-sourced XML is inscrutable to me, and I haven't been able to successfully emulate the structure.

A video by former MS employee Eric White walks through the process but isn't getting me all the way there; an article and example doc are no longer on Microsoft's site and unavailable via archive.org.



Microsoft's current instructions include using Visual Studio (which I have), but the method uses C#, so it's beyond me.
Reply With Quote
  #2  
Old 09-02-2022, 01:24 PM
Charles Kenyon Charles Kenyon is offline Binding Custom XML-Based Items to Content Control Dropdown Windows 11 Binding Custom XML-Based Items to Content Control Dropdown Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,082
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 is beyond me, as well. However you may want to look at:
Reply With Quote
  #3  
Old 09-04-2022, 03:21 PM
Guessed's Avatar
Guessed Guessed is offline Binding Custom XML-Based Items to Content Control Dropdown Windows 10 Binding Custom XML-Based Items to Content Control Dropdown Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
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

As far as I know you can only bind a single xml node to a content control.

I've had no problem binding a node to a dropdown CC and the method is no different to binding a node to a plain text CC. The only complexity with dropdown CCs is that each entry has a display name and a value. The value is what gets stored in the XML node.

Are you trying to populate the dropdown CC options with multiple nodes? As far as I'm aware, that isn't dynamic and you would need to use code to clear the dropdown list and repopulate it from the xml data. This is not mapping.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #4  
Old 09-05-2022, 03:57 AM
Italophile Italophile is offline Binding Custom XML-Based Items to Content Control Dropdown Windows 11 Binding Custom XML-Based Items to Content Control Dropdown Office 2021
Expert
 
Join Date: Mar 2022
Posts: 315
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

Quote:
Originally Posted by Peterson View Post
Microsoft's current instructions include using Visual Studio (which I have), but the method uses C#, so it's beyond me.
The methods in that walkthrough are in both C# and VB
Reply With Quote
  #5  
Old 09-06-2022, 12:20 PM
Peterson Peterson is offline Binding Custom XML-Based Items to Content Control Dropdown Windows 10 Binding Custom XML-Based Items to Content Control Dropdown Office 2019
Competent Performer
Binding Custom XML-Based Items to Content Control Dropdown
 
Join Date: Jan 2017
Posts: 141
Peterson is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
As far as I know you can only bind a single xml node to a content control.

I've had no problem binding a node to a dropdown CC and the method is no different to binding a node to a plain text CC. The only complexity with dropdown CCs is that each entry has a display name and a value. The value is what gets stored in the XML node.

Are you trying to populate the dropdown CC options with multiple nodes? As far as I'm aware, that isn't dynamic and you would need to use code to clear the dropdown list and repopulate it from the xml data. This is not mapping.
Correct: I'm trying to populate the dropdown CC options with multiple nodes. I can see it done with SharePoint-injected column lists, and in the Eric White video in my initial post.

I need to use custom XML because the template I'm working on already uses it extensively, and all data bound to content controls must reside in custom XML; a design requirement is that data can't be in built-in doc properties or the body of the doc.

At one point while trying to create a dropdown content control mapped to a custom XML node, the dropdown items were showing up in document.xml. However, I was not including both names AND values, so it sounds like I need to go back and try that approach. Finally, the dropdown item nodes would be static: it's a list of ~50 items that will never change.
Reply With Quote
  #6  
Old 09-06-2022, 05:17 PM
Guessed's Avatar
Guessed Guessed is offline Binding Custom XML-Based Items to Content Control Dropdown Windows 10 Binding Custom XML-Based Items to Content Control Dropdown Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
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

I just watched Eric's video and the method he uses is different to what I'm used to doing. Digging around that way relies on expert knowledge of what you can and can't do - it will be exceptionally easy to break a file if you add something invalid or remove a necessary node.

Sharepoint injects custom xml in a way that enables you to insert mapped Content Controls via Insert > Quick Parts > Document Property > xxx. Normally there are 15 entries to built-in properties in there but if your Sharepoint template has injected custom xml then you can pick some others which might be what you are looking for.

Are you able to post a sample document that has come out of Sharepoint so we can experiment with the particular custom XML you are working with?

Greg Maxey has done some great work on replicating the Sharepoint xml injections. That may be somewhat relevant to your question although it may just be a distraction if the properties (in para 2 above) are already in the file. Redirecting
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #7  
Old 09-06-2022, 09:46 PM
Peterson Peterson is offline Binding Custom XML-Based Items to Content Control Dropdown Windows 10 Binding Custom XML-Based Items to Content Control Dropdown Office 2019
Competent Performer
Binding Custom XML-Based Items to Content Control Dropdown
 
Join Date: Jan 2017
Posts: 141
Peterson is on a distinguished road
Default

Yes, I'd like to do exactly what you describe: add content controls via Insert > Quick Parts > Document Property.

I'm attaching a sample file that contains SharePoint-injected drop-downs.

A little back story: I'm accustomed to re-purposing built-in doc properties to get repeating content controls. What I've been asked to do for a template I'm working on is, protect the content controls when users need to anonymize documents for external review. When they wipe doc properties via Doc Inspector, as you know, the content controls break. By instead mapping the content controls to custom XML, our users will be able to preserve the content controls even as they strip out author/firm and other identifying info (unless they put the file in a SharePoint doc library that has a column of names).

I'll take a look at the link you provided -- thanks for that.
Attached Files
File Type: docx Test 03 ToSPOAndBack.docx.zip.docx (38.5 KB, 3 views)
Reply With Quote
  #8  
Old 09-07-2022, 01:54 AM
Guessed's Avatar
Guessed Guessed is offline Binding Custom XML-Based Items to Content Control Dropdown Windows 10 Binding Custom XML-Based Items to Content Control Dropdown Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
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

The document you attached doesn't contain any repeating xml content, nor any Sharepoint-injected xml. And the two dropdown CCs contained in the body aren't mapped to your custom XML (which also doesn't contain a node named to align with either Key Personnel or Support Staff). As a result it isn't clear where you think this list information is going to come from nor to what the user selection might map to.

I do see you have mapped CCs in the footer but these aren't dropdowns.
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><AQ_CustomProperties xmlns="http://schemas.aq.com/customDocProperties">
	<AQ_ProjectName></AQ_ProjectName>
	<AQ_ProjectNameShortVersion></AQ_ProjectNameShortVersion>
	<AQ_ProjectNumber></AQ_ProjectNumber>
	<AQ_ReportTitle></AQ_ReportTitle>
	<AQ_ReportTitleShortVersion></AQ_ReportTitleShortVersion>
	<AQ_SpecDivision></AQ_SpecDivision>
	<AQ_SpecSectionName></AQ_SpecSectionName>
	<AQ_SpecSectionNumber></AQ_SpecSectionNumber>
</AQ_CustomProperties>
Psst: It is a very bad idea to map a Rich Text CC to your custom XML.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #9  
Old 11-21-2022, 11:36 PM
Peterson Peterson is offline Binding Custom XML-Based Items to Content Control Dropdown Windows 10 Binding Custom XML-Based Items to Content Control Dropdown Office 2019
Competent Performer
Binding Custom XML-Based Items to Content Control Dropdown
 
Join Date: Jan 2017
Posts: 141
Peterson is on a distinguished road
Default

I must have uploaded an incorrect version of the template way back in September. I unexpectedly had to set aside the work until now.

Thanks for the tip on rich-text CCs -- I'd actually run into issues with that and subsequently went with plain-text.

Today I was messing around with dropdowns again, and I've got a work-around, though it's not exactly what I was looking to do: I'm using dropdown CCs bound to custom parts, which works.
Reply With Quote
  #10  
Old 11-22-2022, 05:30 AM
Charles Kenyon Charles Kenyon is offline Binding Custom XML-Based Items to Content Control Dropdown Windows 11 Binding Custom XML-Based Items to Content Control Dropdown Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,082
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

Do look into Greg's Enhanced Document Properties AddIn.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding Custom XML-Based Items to Content Control Dropdown Change Value of a Content Control based on the value of another content Control jsc_msoffice Word VBA 2 05-21-2021 09:51 PM
Binding Custom XML-Based Items to Content Control Dropdown Auto populate a text field based on Content Control Dropdown List matthias92701 Word VBA 2 05-02-2019 03:54 PM
Word VSTO Content Control binding to XML issue phyrjc Word 0 03-25-2019 08:56 AM
Binding Custom XML-Based Items to Content Control Dropdown Dropdown content control and tables hrzagi Word 1 12-17-2017 09:38 PM
Binding Custom XML-Based Items to Content Control Dropdown Content Control Dropdown Dependencies asteinroeder Word VBA 5 10-28-2015 03:56 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:10 PM.


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