Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-13-2013, 07:59 AM
jamles12 jamles12 is offline how to make building block content control determine bb to display elsewhere Windows 8 how to make building block content control determine bb to display elsewhere Office 2007
Novice
how to make building block content control determine bb to display elsewhere
 
Join Date: Nov 2013
Posts: 5
jamles12 is on a distinguished road
Default how to make building block content control determine bb to display elsewhere


I have a building block content control that has specific building blocks and I would like to have my template place a picture somewhere in the document based on which building block I choose. Any help would be greatly appreciated!
Reply With Quote
  #2  
Old 11-15-2013, 08:25 AM
Charles Kenyon Charles Kenyon is offline how to make building block content control determine bb to display elsewhere Windows 7 64bit how to make building block content control determine bb to display elsewhere Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,125
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Is your building block the picture or a choice? And then the choice determines which picture? Does it also determine the location?
Reply With Quote
  #3  
Old 11-15-2013, 07:09 PM
jamles12 jamles12 is offline how to make building block content control determine bb to display elsewhere Windows 8 how to make building block content control determine bb to display elsewhere Office 2007
Novice
how to make building block content control determine bb to display elsewhere
 
Join Date: Nov 2013
Posts: 5
jamles12 is on a distinguished road
Default

I have a building block content control with about 6 different choices of building blocks and depending on which building block determines which picture is displayed on the cover page so the picture is always is the same position. I actually got it sort of working by placing a bookmark and then using autotext building blocks with the code below. The problem is that it is looking for a specific word in the autotext to work so in other words since the below code looks for case Apple in the contentcontrol.range.text it only works if the original buildingblock contains the word Apple and only the word Apple! Im sure that I just need to change the ContentControl.Range.Text to something that would just look at the name of the buildingblock but I dont know how to so any help would mean a ton to me right now. Thank you for looking.

Code:
Dim oRng As Word.Range
  Select Case ContentControl.Title
   
    Case "Fruit"
    
      Select Case ContentControl.Range.Text
        Case "Apple"
          InsertBBEinBM "Fruit", "Apple"
        Case "Orange"
          InsertBBEinBM "Fruit", "Orange"
        Case "Pear"
          InsertBBEinBM "Fruit", "Pear"
        Case Else
          InsertBBEinBM "Fruit", " "
      End Select
    
    
  End Select
lbl_Exit:
  Exit Sub
End Sub


Sub InsertBBEinBM(ByRef pBMTarget As String, pBBEName As String)
Dim oRng As Word.Range
  With ActiveDocument
    Set oRng = .Bookmarks(pBMTarget).Range
    If Not pBBEName = " " Then
      Set oRng = .AttachedTemplate.BuildingBlockTypes(wdTypeAutoText).Categories("Fruit") _
                 .BuildingBlocks(pBBEName).Insert(oRng, True)
    Else
      oRng.Text = ""
    End If
    .Bookmarks.Add pBMTarget, oRng
  End With
lbl_Exit:
  Exit Sub
End Sub
Reply With Quote
  #4  
Old 11-16-2013, 08:22 AM
gmaxey gmaxey is offline how to make building block content control determine bb to display elsewhere Windows 7 32bit how to make building block content control determine bb to display elsewhere Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
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

Try changing your second select statement to:

Select Case True
Case InStr(ContentControl.Range.Text, "apple") > 0


Of course "apple" (and the word you use in the other case statements) must be unique.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 11-16-2013, 11:32 AM
jamles12 jamles12 is offline how to make building block content control determine bb to display elsewhere Windows 8 how to make building block content control determine bb to display elsewhere Office 2007
Novice
how to make building block content control determine bb to display elsewhere
 
Join Date: Nov 2013
Posts: 5
jamles12 is on a distinguished road
Default

That gets me much closer thanks! but is there anyway to choose it by the name of the building block instead of text within it?
Reply With Quote
  #6  
Old 11-16-2013, 11:38 AM
gmaxey gmaxey is offline how to make building block content control determine bb to display elsewhere Windows 7 32bit how to make building block content control determine bb to display elsewhere Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
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

"...but is there anyway to choose it by the name of the building block instead of text within it?"

Not that I can find. The content control has a BuildingBlockType and Category Property but there is nothing that returns the name of the building blocks are the building block selected.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply

Tags
help please, macro, macropod



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make building block content control determine bb to display elsewhere Deleting a table from a content control -- preserving the content control BrainSlugs83 Word Tables 8 11-14-2013 03:06 AM
how to make building block content control determine bb to display elsewhere Content control problem Anja Word 2 10-16-2013 09:56 AM
Building blocks show correctly in dropdown, but wrong building block populates in doc wordgirl123 Word 0 10-03-2013 08:30 AM
how to make building block content control determine bb to display elsewhere Hierarchical content control ntjson Word VBA 1 04-04-2013 12:07 AM
Retrieving content control value jillapass Word VBA 4 05-24-2012 05:07 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:57 AM.


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