Regarding [SOLVED] Code to insert a building block via a check box (vbaexpress.com)
I'm trying the following
Schermafbeelding 2022-07-12 090831.png
If Mobile is Yes then Building block With mobile phone is inserted at Bookmark MainText
If Mobile is No then Building block Without mobile phone is inserted at Bookmark MainText
Private Sub CancelButton_Click()
UserInfo.Hide
End Sub
Private Sub OkButton_Click()
Set ovars = ActiveDocument.Variables
Dim oRng As Word.Range
If OptionButton1.Value Then
Set oRng = ThisDocument.AttachedTemplate.BuildingBlockTypes(wdTypeAutoText). _
Categories("general").BuildingBlocks("With mobiel phone").Insert(ActiveDocument.Bookmarks("MainText").Range, True)
ActiveDocument.Bookmarks.Add "MainText", oRng
End If
If OptionButton2.Value Then
Set oRng = ThisDocument.AttachedTemplate.BuildingBlockTypes(wdTypeAutoText). _
Categories("general").BuildingBlocks("Without mobiel phone").Insert(ActiveDocument.Bookmarks("MainText").Range, True)
ActiveDocument.Bookmarks.Add "MainText", oRng
End If
Hide
Me.Hide
ActiveDocument.Fields.Update
Unload Me
End Sub
I'm getting Error 591.
Any ideas?
As an extra I would like to have the oportunity to insert an image (if possible) and have it inserted at Bookmark space Image.