Word: Remove content when UserForm CheckBox is unchecked. VBA

JamesHayek

New Member
Joined
May 24, 2016
Messages
20
Hello All!

I am using Bookmarks and a UserForm to populate data in Word. My apologies if this is on the wrong forum. I am using VBA and assumed it is similar.

After setting my bookmarks and creating a user form, I can populate text in my word document with the following:

Code:
Private Sub WSP01_700LTE_Click()


If Me.WSP01_700LTE.Value = True Then
    Set oRng05 = ActiveDocument.Bookmarks("Freq01a").Range
    oRng05.Text = "700 LTE"
    ActiveDocument.Bookmarks.Add "Freq01a", oRng05
End If
    
End Sub

Where WSP01_700LTE is my checkbox name and Freq01a is my bookmark.
The line oRng05.Text = "700 LTE" will populate the Word document with 700 LTE

But what if I want that line removed if the check box is unchecked?


Thanks in advance!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
And what do you expect to happen if the user re-checks the checkbox - or is there a process that exits the userform so the deletion, if appropriate, can be done then?
 
Upvote 0
If the user toggles the checkbox, I expect nothing to happen. The only time anything happens, based on the options, is when the form is submitted using the enter button.

I do not expect the user to reopen the UserForm once competed.
 
Upvote 0
If the user toggles the checkbox, I expect nothing to happen. The only time anything happens, based on the options, is when the form is submitted using the enter button.
Presumably, then, WSP01_700LTE_Click is not the Sub corresponding to the 'Enter' button, whatever that is. What is that sub?

Also, what title or tag does your content control have?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,605
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top