Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-12-2015, 08:03 PM
HighSierra HighSierra is offline A yes or no OptionButton in Userform inserts a building block Windows XP A yes or no OptionButton in Userform inserts a building block Office 2010 64bit
Novice
A yes or no OptionButton in Userform inserts a building block
 
Join Date: May 2015
Posts: 7
HighSierra is on a distinguished road
Default A yes or no OptionButton in Userform inserts a building block

Hi All,

I've spent hours trying to figure this out.... I feel really certain this is possible.

I have a question in a Userform with OptionButton 13 and 12 corresponding to Yes or No. If the user selects Yes, I want a buildingblock that I already created in the template called AddtValSiteBB to insert after a bookmark already existing in the template. If no, I want nothing to happen.

I have this so far:

Private Sub CommandButton1_Click()

Dim AddtValSiteBB As BuildingBlock
If OptionButton13 = True Then AddtValSiteBB =
If OptionButton13 = False Then AddtValSiteBB = " "



End If


With ActiveDocument
.Bookmarks("AddtValSites").Range _
.InsertAfter AddtValSiteBB
End With

End Sub


I tried all sorts of ways to define the AssValSiteBB as the building block in the active document...to no avail...

Any help would be AMAZING.

Thanks!
Reply With Quote
  #2  
Old 06-14-2015, 07:32 AM
gmayor's Avatar
gmayor gmayor is offline A yes or no OptionButton in Userform inserts a building block Windows 7 64bit A yes or no OptionButton in Userform inserts a building block Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,105
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The following should work if the builkding block is stored in the document template

Code:
Private Sub CommandButton1_Click()
Dim oRng As Range
    Me.Hide
    If Me.OptionButton13.Value = True Then
        Set oRng = ActiveDocument.Bookmarks("AddtValSites").Range
        ActiveDocument.AttachedTemplate.BuildingBlockEntries("AddtValSiteBB").Insert _
                Where:=oRng
    End If
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 06-14-2015, 08:17 PM
HighSierra HighSierra is offline A yes or no OptionButton in Userform inserts a building block Windows XP A yes or no OptionButton in Userform inserts a building block Office 2010 64bit
Novice
A yes or no OptionButton in Userform inserts a building block
 
Join Date: May 2015
Posts: 7
HighSierra is on a distinguished road
Default

!!!! THANK YOU !!!!

That totally worked - I hadn't really gotten used to using oRng ranges. Thank you!
Reply With Quote
  #4  
Old 06-14-2015, 11:19 PM
gmayor's Avatar
gmayor gmayor is offline A yes or no OptionButton in Userform inserts a building block Windows 7 64bit A yes or no OptionButton in Userform inserts a building block Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,105
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You don't actually need the range name on this occasion, though I tend to use them through force of habit.
Code:
ActiveDocument.AttachedTemplate.BuildingBlockEntries("AddtValSiteBB").Insert _
                Where:=ActiveDocument.Bookmarks("AddtValSites").Range
would have done the job.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How-to: Add a quickpart, field or Building Block Gallery Content Control based on a UserForm HighSierra Word VBA 0 05-06-2015 08:20 PM
A yes or no OptionButton in Userform inserts a building block How to share building block macros? rdross51 Word VBA 7 03-12-2015 08:59 AM
A yes or no OptionButton in Userform inserts a building block Custom Building Block File Locations ptmuldoon Word 5 01-03-2015 08:45 AM
how to make building block content control determine bb to display elsewhere jamles12 Word VBA 5 11-16-2013 11:38 AM
Building blocks show correctly in dropdown, but wrong building block populates in doc wordgirl123 Word 0 10-03-2013 08:30 AM

Other Forums: Access Forums

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