Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-13-2012, 01:00 PM
brent.fraser brent.fraser is offline Cross Reference to Content Control Windows 7 32bit Cross Reference to Content Control Office 2010 32bit
Novice
Cross Reference to Content Control
 
Join Date: Dec 2012
Posts: 7
brent.fraser is on a distinguished road
Default Cross Reference to Content Control

Hi all,



I am creating a document in word 2010 with a userform to populate many text content controls (which is working fine). I am trying to create a cross-reference to one of my text content controls and place the information in the footer.

I have used assigned a bookmark (including a space before and after the content control) then inserted a cross-reference usung Insert > Cross-reference and navigating to the bookmark. When I do this and update the information with the userform, the reference updates but not the original text content control.

I have also used a styleref and that works but when i update the document using the userform, the styleref does not automatically update.

Does anyone know what the best way to handle this is? I am not sure why the first one does not work..... it's beyond me but it doesn't.

The only other substitute I can think of is have another content control and pass the information in the userform to two places......

Anyway, thanks for any guidance out there.

Brent
Reply With Quote
  #2  
Old 12-13-2012, 02:55 PM
gmaxey gmaxey is offline Cross Reference to Content Control Windows 7 32bit Cross Reference to Content Control Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Brent,

I'll say it again. If you are going to use content controls, then why won't you use mapped content controls? http://gregmaxey.com/word_tip_pages/...ols_addin.html
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 12-13-2012, 03:01 PM
brent.fraser brent.fraser is offline Cross Reference to Content Control Windows 7 32bit Cross Reference to Content Control Office 2010 32bit
Novice
Cross Reference to Content Control
 
Join Date: Dec 2012
Posts: 7
brent.fraser is on a distinguished road
Default

Hey Greg,

Fancy seeing you here... haha. I was trying to give you a break on the other forum and poof, here you are.

I don't know anything about mapped content controls but I guess I am going to learn. Thanks for the link.

B.
Reply With Quote
  #4  
Old 12-13-2012, 03:14 PM
macropod's Avatar
macropod macropod is offline Cross Reference to Content Control Windows 7 64bit Cross Reference to Content Control Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Brent,

The Content Control/STYLEREF combination works fine for me. Of course, the STYLEREF field must be located in the document header/footer. No vba required.

Also, rather than relying on content controls, bookmarks, cross-references and/or STYLEREF fields, I'd suggest you consider populating custom document properties with your userform (which makes it easy to read back the properties into the userform when the document is re-opened) and combine those with DOCPROPERTY fields wherever you want to custom document property values to appear. With this approach, you don't need duplicate custom document properties for each time a value from the userform is to appear - simply add another DOCPROPERTY field to the document pointing to the same custom document property.

The attached document (cobbled together for a different query) uses content controls to populate a series of custom document properties, and DOCPROPERTY fields to replicate those values. The principle is the same for use with a userform.

PS: Please don't multi-post the same question. I've deleted the separate thread.
Attached Files
File Type: zip CCtrl DocProp.zip (32.8 KB, 163 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 12-13-2012, 03:34 PM
gmaxey gmaxey is offline Cross Reference to Content Control Windows 7 32bit Cross Reference to Content Control Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Paul,

That of course will work. The reason I am proding Brent toward mapped content controls, is because they are so simple to set up and once done there is no need to have a on exit macro.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #6  
Old 12-13-2012, 03:39 PM
brent.fraser brent.fraser is offline Cross Reference to Content Control Windows 7 32bit Cross Reference to Content Control Office 2010 32bit
Novice
Cross Reference to Content Control
 
Join Date: Dec 2012
Posts: 7
brent.fraser is on a distinguished road
Default

Thanks fellas,

I am investigating both right now. The one you suggested Paul works. I want to look onto Greg's as well so I can learm about it and make them both work.

Thank you again guys.

B.
Reply With Quote
  #7  
Old 12-13-2012, 04:06 PM
macropod's Avatar
macropod macropod is offline Cross Reference to Content Control Windows 7 64bit Cross Reference to Content Control Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by gmaxey View Post
Paul,

That of course will work. The reason I am proding Brent toward mapped content controls, is because they are so simple to set up and once done there is no need to have a on exit macro.
Hi Greg,

My reply was originally to a duplicate post by Brent in another thread. At the time, I wasn't aware of your separate reply. I've merged the threads since, which is why you now see my reply here and why we appear to be working at cross purposes.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 12-13-2012, 05:45 PM
gmaxey gmaxey is offline Cross Reference to Content Control Windows 7 32bit Cross Reference to Content Control Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Brent,

The following (very little error handling) should suffice for most simple mapping requirements. Just add titled CCs in your document and run the code. Copy and paste any titled CC to a new location and it is automatically mapped to the data node (and all other like titled CCs).

Code:
Sub MapAColectionOfCustomXMLParts()
Dim oCCs As New Collection
Dim oCXPart As CustomXMLPart
Dim oCC As ContentControl
Dim lngIndex As Long
Dim strTitle As String
  'Create a fresh CustomXMLPart for mapping.
  On Error Resume Next
  'Kill any existing CustomXMLPart used previously.
  Set oCXPart = ActiveDocument.CustomXMLParts.SelectByNamespace _
               ("http//mapCCcollection@namespace.com").Item(1)
  If Err.Number = 0 Then
    oCXPart.Delete
  End If
  On Error GoTo 0
  'Create the new CustomXMLPart.
  ActiveDocument.CustomXMLParts.Add _
                ("<CC_Collection xmlns='http//mapCCCollection@namespace.com'/>")
  Set oCXPart = ActiveDocument.CustomXMLParts.SelectByNamespace _
                ("http//mapCCCollection@namespace.com").Item(1)
 
  'Get unique titles.
  For Each oCC In ActiveDocument.ContentControls
    If oCC.Title <> "" Then
      On Error Resume Next
      oCCs.Add oCC, oCC.Title
    End If
  Next oCC
  On Error GoTo 0
 
  For lngIndex = 1 To oCCs.Count
    'Add a CustomXMLNode for eacj uniqued titled CC.
     Set oCC = oCCs(lngIndex)
     strTitle = Replace(oCC.Title, " ", "_")
     oCXPart.AddNode oCXPart.SelectSingleNode("ns0:CC_Collection"), _
                            strTitle, , , msoCustomXMLNodeElement
  Next lngIndex
  'Map titled CCs.
  For Each oCC In ActiveDocument.ContentControls
    If oCC.Title <> "" Then
      oCC.XMLMapping.SetMappingByNode oCXPart.SelectSingleNode("//" & Replace(oCC.Title, " ", "_") & "[1]")
    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
  #9  
Old 12-13-2012, 06:27 PM
gmaxey gmaxey is offline Cross Reference to Content Control Windows 7 32bit Cross Reference to Content Control Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Paul,

No worries. Anything that you post is something well posted, cross purposed or not.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #10  
Old 12-14-2012, 11:57 AM
brent.fraser brent.fraser is offline Cross Reference to Content Control Windows 7 32bit Cross Reference to Content Control Office 2010 32bit
Novice
Cross Reference to Content Control
 
Join Date: Dec 2012
Posts: 7
brent.fraser is on a distinguished road
Default Thanks for your help fellas

Hey guys,

Thanks for your help. Unfortunately nothing that you have suggested has worked and I don't know why. I have been working at it for hours and something as simple as referencing existing information isn't working. I even have an "updateAllRefFields" that is supposed to update the cross references once the information is updated via userform but nope, that doesn't work either....

Also, I am not the administrator for my computer (work) so the add-in that Greg provided can't be installed on my PC.

I truly appreciate all your suggestions and guidance.

I am going to try something else and see if that works.

Have a good one fellas.

Brent
Reply With Quote
  #11  
Old 12-14-2012, 12:43 PM
macropod's Avatar
macropod macropod is offline Cross Reference to Content Control Windows 7 64bit Cross Reference to Content Control Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Brent,

FWIW, the approach I demonstrated doesn't use REF fields, but DOCPROPERTY fields. So, if your code refers specifically to REF fields, it's not going to update DOCPROPERTY fields (but closing & re-opening the document will).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cross Reference to Content Control Need help with using bookmark and cross-reference mpdsal Word 1 07-26-2012 01:05 PM
Cross-reference problem Marineboy Word 2 08-05-2011 03:37 AM
Cross Reference to Content Control How to control the caption and their Cross-reference? Jamal NUMAN Word 1 04-10-2011 03:23 PM
2 figures cross reference mmdmov Word 0 05-05-2010 09:12 AM
How do I return from a cross reference? smoggymark Word 0 10-21-2008 07:45 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:06 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