Results 1 to 9 of 9

Thread: Populate paragraphs in document based on Userform Checkboxes

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,411
    Location
    Private Sub CommandButton1_Click()
    Dim oTmp As Template
    Dim oCC As ContentControl
    Dim oRng As Range
      'Set oCC = ActiveDocument.SelectContentControlsByTitle("ccTIFI").Item(1)
      Select Case True
        Case CheckBox1 And CheckBox2
          
        Case CheckBox2 And CheckBox3
          
        Case CheckBox1 And CheckBox3
          
      End Select
    End Sub
    Greg

    Visit my website: http://gregmaxey.com

  2. #2
    Hi Greg, I was able to get that code to work sort of.

    Essentially the code is working but it doesn't like my building blocks and IDK why!

    Here is my code:

    Dim oCCA As ContentControl
    Set oCCA = ActiveDocument.SelectContentControlsByTitle("ccINTROACTION").Item(1)
    Select Case True
    Case chbTR And Not chbAccounts
    Set oTmp = Templates("C:\Users\sarahjane.munt\AppData\Roaming\Microsoft\Templates\Norm al.dotm")
    oTmp.BuildingBlockEntries("bbTRONLY").Insert Where:=oCCA.Range, RichText:=True

    Case chbTR And chbR185
    Set oTmp = Templates("C:\Users\sarahjane.munt\AppData\Roaming\Microsoft\Templates\Norm al.dotm")
    oTmp.BuildingBlockEntries("bbTRR185").Insert Where:=oCCA.Range, RichText:=True
    End Select

    Now if I try to run this it tells me there is an insert error on the building block line: Method 'Insert' of object 'BuildingBlock' failed

    But if I substitute either of my my building blocks (bbTRONLY or bbTRR185) with bbTIFI from my earlier code then the code works fine! I don't understand why it would like one buildingblock and not another. I have checked that all the buildingblock properties are all the same for all buildingblocks and they are all saved in my Normal.dotm file.

    Any ideas what the problem might be? Is it possible my building blocks are just corrupted?

    Thanks

Tags for this Thread

Posting Permissions

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