ContentControl Tag & Title are limited to 64 chars - where can I store very long strings?

C

Colbert Zhou [MSFT]

Hello Dave,

We can store the long string in ContentControl's CustomXML. In details, the
ContentControl.XMLMapping.CustomXMLPart has a description node. So we can
store the long string there,

The following VBA codes work fine for me,
Sub Test()
Dim description As CustomXMLNode
Set description =
ActiveDocument.ContentControls(1).XMLMapping.CustomXMLPart.SelectSingleNode(
"/ns1:coreProperties[1]/ns0:description[1]")
description.Text =
"ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
ttttttttttttttttt"
End Sub

Sub Test2()
Dim description As CustomXMLNode
Set description =
ActiveDocument.ContentControls(1).XMLMapping.CustomXMLPart.SelectSingleNode(
"/ns1:coreProperties[1]/ns0:description[1]")
Debug.Print description.Text
End Sub

Test Sub set a 90+ characters long string and Test2 Sub prints it out.


Best regards,
Ji Zhou
Microsoft Online Community Support
 
D

David Thielen

Hi;

I tried this and I am getting:
+ ctrl.XMLMapping.CustomXMLPart
'ctrl.XMLMapping.CustomXMLPart' threw an exception of type
'System.Runtime.InteropServices.COMException'
Microsoft.Office.Core.CustomXMLPart
{System.Runtime.InteropServices.COMException}

System.Runtime.InteropServices.COMException occurred
Message="Error HRESULT E_FAIL has been returned from a call to a COM
component."
Source="Microsoft.Office.Interop.Word"
ErrorCode=-2147467259
StackTrace:
at Microsoft.Office.Interop.Word.XMLMapping.get_CustomXMLPart()
at
AutoTag2010.net.windward.autotag.word.WordTagHandler.FindAllTags(Selection
selOn, Boolean justFirst, Int32 startSearch, Int32 endSearch) in
C:\src\version9\AutoTag\AutoTag2010\net\windward\autotag\word\WordTagHandler.cs:line
545
InnerException:

??? - thanks - dave


Hello Dave,

We can store the long string in ContentControl's CustomXML. In details, the
ContentControl.XMLMapping.CustomXMLPart has a description node. So we can
store the long string there,

The following VBA codes work fine for me,
Sub Test()
Dim description As CustomXMLNode
Set description =
ActiveDocument.ContentControls(1).XMLMapping.CustomXMLPart.SelectSingleNode(
"/ns1:coreProperties[1]/ns0:description[1]")
description.Text =
"ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
ttttttttttttttttt"
End Sub

Sub Test2()
Dim description As CustomXMLNode
Set description =
ActiveDocument.ContentControls(1).XMLMapping.CustomXMLPart.SelectSingleNode(
"/ns1:coreProperties[1]/ns0:description[1]")
Debug.Print description.Text
End Sub

Test Sub set a 90+ characters long string and Test2 Sub prints it out.


Best regards,
Ji Zhou
Microsoft Online Community Support


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
D

David Thielen

I tried adding:
ctrl.XMLMapping.SetMapping("/ns1:coreProperties[1]/ns0:description[1]",
null, null);

And that works - except that while test2() works if called immediately
after calling test() - calling test() later returns an empty string.
So it is losing the data.

??? - thanks - dave


Hello Dave,

We can store the long string in ContentControl's CustomXML. In details, the
ContentControl.XMLMapping.CustomXMLPart has a description node. So we can
store the long string there,

The following VBA codes work fine for me,
Sub Test()
Dim description As CustomXMLNode
Set description =
ActiveDocument.ContentControls(1).XMLMapping.CustomXMLPart.SelectSingleNode(
"/ns1:coreProperties[1]/ns0:description[1]")
description.Text =
"ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
ttttttttttttttttt"
End Sub

Sub Test2()
Dim description As CustomXMLNode
Set description =
ActiveDocument.ContentControls(1).XMLMapping.CustomXMLPart.SelectSingleNode(
"/ns1:coreProperties[1]/ns0:description[1]")
Debug.Print description.Text
End Sub

Test Sub set a 90+ characters long string and Test2 Sub prints it out.


Best regards,
Ji Zhou
Microsoft Online Community Support


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
D

David Thielen

Please don't forget this question.

thanks - dave


Hello Dave,

We can store the long string in ContentControl's CustomXML. In details, the
ContentControl.XMLMapping.CustomXMLPart has a description node. So we can
store the long string there,

The following VBA codes work fine for me,
Sub Test()
Dim description As CustomXMLNode
Set description =
ActiveDocument.ContentControls(1).XMLMapping.CustomXMLPart.SelectSingleNode(
"/ns1:coreProperties[1]/ns0:description[1]")
description.Text =
"ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
ttttttttttttttttt"
End Sub

Sub Test2()
Dim description As CustomXMLNode
Set description =
ActiveDocument.ContentControls(1).XMLMapping.CustomXMLPart.SelectSingleNode(
"/ns1:coreProperties[1]/ns0:description[1]")
Debug.Print description.Text
End Sub

Test Sub set a 90+ characters long string and Test2 Sub prints it out.


Best regards,
Ji Zhou
Microsoft Online Community Support


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
D

David Thielen

Hi;

Please try running
http://www.windwardreports.com/temp/ContentControlCustomXml.zip. It
adds the CustomXML fine - but then loses it. And in the docx file it
has the CustomXML in document.xml, but not in core.xml.

It also looks like they all share that one CustomXML node so you could
not have multiple ContentControls each with a different value - I
think.

??? - thanks - dave


Hello Dave,

We can store the long string in ContentControl's CustomXML. In details, the
ContentControl.XMLMapping.CustomXMLPart has a description node. So we can
store the long string there,

The following VBA codes work fine for me,
Sub Test()
Dim description As CustomXMLNode
Set description =
ActiveDocument.ContentControls(1).XMLMapping.CustomXMLPart.SelectSingleNode(
"/ns1:coreProperties[1]/ns0:description[1]")
description.Text =
"ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
ttttttttttttttttt"
End Sub

Sub Test2()
Dim description As CustomXMLNode
Set description =
ActiveDocument.ContentControls(1).XMLMapping.CustomXMLPart.SelectSingleNode(
"/ns1:coreProperties[1]/ns0:description[1]")
Debug.Print description.Text
End Sub

Test Sub set a 90+ characters long string and Test2 Sub prints it out.


Best regards,
Ji Zhou
Microsoft Online Community Support


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
D

David Thielen

Hi;

We hit a problem with the approach of saving a hashtable of guids
(assigned to Tag) and our text - what happens when the user copies a
content control in one word doc and pastes it in another word doc.

The hashtable does not go with the paste - and we've lost our text we
need tied to the content control. Can you think of a way to do this
where our text is kept with the content control, even on a copy/paste?

thanks - dave


Hello Dave,

We can store the long string in ContentControl's CustomXML. In details, the
ContentControl.XMLMapping.CustomXMLPart has a description node. So we can
store the long string there,

The following VBA codes work fine for me,
Sub Test()
Dim description As CustomXMLNode
Set description =
ActiveDocument.ContentControls(1).XMLMapping.CustomXMLPart.SelectSingleNode(
"/ns1:coreProperties[1]/ns0:description[1]")
description.Text =
"ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
ttttttttttttttttt"
End Sub

Sub Test2()
Dim description As CustomXMLNode
Set description =
ActiveDocument.ContentControls(1).XMLMapping.CustomXMLPart.SelectSingleNode(
"/ns1:coreProperties[1]/ns0:description[1]")
Debug.Print description.Text
End Sub

Test Sub set a 90+ characters long string and Test2 Sub prints it out.


Best regards,
Ji Zhou
Microsoft Online Community Support


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
C

Colbert Zhou [MSFT]

Hello Dave,

The Copy and Paste scenario is very complicated. Especially if the source
word application and the target word application are not the same process,
I am afraid we can do little to work around the limitation. I will do some
more researches and investigations on this and then follow up. :)


Best regards,
Ji Zhou
Microsoft Online Community Support
 
D

David Thielen

You've said it.

Is there any other field in the ContentControl? Or can we place
CustomXML inside the ContentControl?

thanks - dave


Hello Dave,

The Copy and Paste scenario is very complicated. Especially if the source
word application and the target word application are not the same process,
I am afraid we can do little to work around the limitation. I will do some
more researches and investigations on this and then follow up. :)


Best regards,
Ji Zhou
Microsoft Online Community Support


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top