Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 09-26-2018, 10:31 AM
gmaxey gmaxey is offline Get value from Content control from SharePoint document Windows 7 32bit Get value from Content control from SharePoint document Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Your content control in the document showing "Contract" is a richtext content control. The "Value" stored in the customXMLPart is the entire OpenOfficeXMLContent package associated with a word document which contains the single word "Contract."

You can see this if you delete the content control and insert a new mapped "Plain Text" CC to that node. You will end up with several pages of XML gobbledeegook.

You can extract the text content from that using:

Code:
Sub ScratchMacro2()
'A basic Word macro coded by Greg Maxey, http://gregmaxey.com/word_tips.html, 9/25/2018
Dim oCC As ContentControl
Dim oNode As CustomXMLNode
Dim strContent As String
Dim arrParts() As String
  For Each oCC In ActiveDocument.ContentControls 'You only have one.
    If oCC.XMLMapping.IsMapped Then
      Set oNode = oCC.XMLMapping.CustomXMLNode.SelectSingleNode(oCC.XMLMapping.XPath)
      strContent = oNode.Text
      arrParts = Split(strContent, "w:t>")
      strContent = Left(arrParts(1), Len(arrParts(1)) - 2)
      MsgBox strContent
      Set oNode = Nothing
    End If
  Next oCC
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Content Control content deleted when re-uploading to SharePoint Peterson Word 5 06-27-2018 08:13 PM
Combo Box Content Control: How to update the list throughout the whole document? deepak_fer Word 9 03-18-2018 04:10 AM
Gallery Content control and protect document DarrenOakey Word 2 08-13-2015 04:56 AM
How to protect all parts of a document not in a content control? XmisterIS Word 2 05-20-2014 04:59 AM
Get value from Content control from SharePoint document Deleting a table from a content control -- preserving the content control BrainSlugs83 Word Tables 8 11-14-2013 03:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:31 PM.


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