Word macro buttons - I need to reset them, but don't know how once they execute the first time

stressler

Board Regular
Joined
Jun 25, 2014
Messages
95
I am creating a Word document that has several buttons associated to a macro. However, once I execute the form button the first time, there isn't any way for me to remove the response provided by the macro and re-execute the button again. So in simpler terms, I have several buttons that when double clicked, provide me with a "Yes" text response. If I delete my Yes response, that button no longer seems to be active, when I double click it, nothing happens.

Do you know if a way to reset the macro buttons or allow me to delete the response provided by the macro button and then re-execute to provide the "Yes" response again?

Here's what I have so far...

Sub Macro1SUM()
'
' Macro1SUM Macro
' When this button is pushed, the form will auto-fill with 1SUM as the selection.
'
Selection.TypeText Text:="1SUM Yes"
End Sub
Sub MacroREDE()
'
' MacroREDE Macro
' When this button is pushed, the form will auto-fill with REDE as the selection.
'
Selection.TypeText Text:="REDE Yes"
End Sub
Sub MacroBoth()
'
' MacroBoth Macro
' When this button is pushed, the form will auto-fill with Both as the selection.
'
Selection.TypeText Text:="Both Yes"
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
The way your macro is coded, it outputs the text to wherever the cursor happens to be, which is less than ideal. What you should do is create a bookmark in the document where you want the output to go. Then you could use code like:
Code:
Const StrBkMk As String = "MyBookmark"

Sub Macro1SUM()
Call UpdateBookmark(StrBkMk, "1SUM Yes")
End Sub

Sub MacroREDE()
Call UpdateBookmark(StrBkMk, "REDE Yes")
End Sub

Sub MacroBoth()
Call UpdateBookmark(StrBkMk, "Both Yes")
End Sub

Sub UpdateBookmark(StrBkMkNm As String, StrTxt As String)
Dim BkMkRng As Range
With ActiveDocument
  If .Bookmarks.Exists(StrBkMkNm) Then
    Set BkMkRng = .Bookmarks(StrBkMkNm).Range
    BkMkRng.Text = StrTxt
    .Bookmarks.Add StrBkMkNm, BkMkRng
  End If
End With
Set BkMkRng = Nothing
End Sub
 
Upvote 0
I really like the bookmarking suggestion, it's very clean, which is nice. However, I still have the same issue. Once I execute the macro, there's no way for me to remove the macro response and reset the buttons. Meaning, if I delete the 1SUM Yes or REDE Yes or Both Yes, then try to double click my macro buttons again, nothing happens. How can I reset them so that they can be used again?
 
Upvote 0
With the code I posted, clicking any button will update the bookmarked range. So, click on the macrobutton for 'Macro1SUM' and you'll get "1SUM Yes". If you then click on the macrobutton for 'MacroREDE' the output will update to "REDE Yes". If you want to clear the bookmark, you need to update it with no text. For example:
Code:
Sub MacroClear()
Call UpdateBookmark(StrBkMk, "")
End Sub
 
Upvote 0

Forum statistics

Threads
1,226,113
Messages
6,189,046
Members
453,522
Latest member
Seeker2025

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