Count how many times I use a macro in Word

0

my problem is, I have a macro opens a UserForm that gives two options one to paste text and another to paste images. My problem arises when I want to create another macro, a counter that shows in an Msgbox how many times each one uses or at least how many times it executes the first macro (the one that opened the userform), the truth always battled with the counters so that I would appreciate your help

    
asked by Carlos.M 26.11.2017 в 01:52
source

1 answer

0

You can declare an entire global variable that bears the account.

For this, simply declare the variable outside the function:

Public contador As Integer

Private Sub Ejemplo1_Click()
    contador = contador + 1
    MsgBox ("Se ha presionado " & contador & " veces")
End Sub

Your macro should look something like this:

Public contador As Integer

Sub TuMacro()
contador = contador + 1   ' suma 1 al contador

' Realizas más acciones del macro...

End Sub
    
answered by 26.11.2017 / 07:07
source