View Single Post
 
Old 11-20-2012, 09:26 AM
RobsterCraw RobsterCraw is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Nov 2012
Posts: 11
RobsterCraw is on a distinguished road
Default

Ok an update... Again thank you to gmaxey for all his help.

I had to clear a few errors from the code but I still don't know how to fix the one error that keeps cropping up.
It has to do with the fact that if there are more than one CC in the document with the same title already, the following statements will only except the first, and then error on the second (or so it seems). How can I write the following exception differently so that it excludes all existing CCs?

HTML Code:
        If Not oRng.InRange(ActiveDocument.SelectContentControlsByTitle(oCCTitle).Item(1).Range) Then
            'The following line gives me a command failed error when there are more than one existing CCs
            'with the same title. Sometimes the error is
            Set oCC = ActiveDocument.ContentControls.Add(wdContentControlText, oRng)
            oCC.XMLMapping.SetMapping (ActiveDocument.SelectContentControlsByTitle(oCCTitle).Item(1).XMLMapping.xPath)
            oCC.Title = oCCTitle
            oRng.Collapse wdCollapseEnd
        End If
Reply With Quote