Consulting

Results 1 to 3 of 3

Thread: RichText content control anomoly

  1. #1
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,335
    Location

    RichText content control anomoly

    This is an observation that I wanted to share (not a question). While working on a project today, I discovered that you can't insert a buildingblock containing multiple paragraphs in a document richtext content control unless that content control is the unique element in a paragraph.

    To illustrate,

    1. I created a building block "ML" containing multiple paragraphs
    2. I added a richtext content control titled "shareline" to a paragraph containing a few words i.e., "Test, test: richtextCC"
    3. I added a richtext content control titled "devotedline" to an empty paragraph

    I ran the following code:

    Sub DemoIssue()
    Dim oCC1 As ContentControl
    Dim oCC2 As ContentControl
    Dim oDoc As Document
      Set oDoc = ActiveDocument
      Set oCC1 = oDoc.SelectContentControlsByTitle("shareline").Item(1) 'error occurs
      Set oCC2 = oDoc.SelectContentControlsByTitle("devotedline").Item(1)
      On Error GoTo Err_Handler
      oDoc.AttachedTemplate.BuildingBlockEntries("ML").Insert oCC1.Range
      oDoc.AttachedTemplate.BuildingBlockEntries("ML").Insert oCC2.Range
    lbl_exit:
      Exit Sub
    Err_Handler:
      If Err.Number = -2147467259 Then
        MsgBox "You cannot insert a building block containing multiple paragraphs into a richtext content " _
         & "control unless that content control is the unique content of a paragraph.", vbInformation + vbOKOnly, "INVALID ACTION"
      End If
      Resume Next
    End Sub
    This is not just a VBA anomaly. If you try to insert a buildingblock containing multiple paragraphs from Insert>QuickParts>BuildingBlock Organizer into a richtext control not by itself in a paragraph, you get nothing inserted. If you try to copy and paste multiple paragraphs into to a richtext CC not by itself, the paragraphs are stripped out of the content pasted.
    Greg

    Visit my website: http://gregmaxey.com

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,055
    Location
    So it becomes an order of hierarchy then in order for you to proceed?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,335
    Location
    The demo was just to show that you can't insert a multiline BB in a richtext control if that control is part of other text in the paragraph (oCC1) while you can in a richtext CC that is the only content in a paragraph (oCC2)
    Greg

    Visit my website: http://gregmaxey.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •