Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Access to Variable in VBA Script

Hello everyone,

I created a certain variable in QV Variable overview tool and now I would like to use it in a VBA script I run with the push of a button.

The only thing i do not know how to do is get the variable value in VBA.

The name of my variable is "mensal"

My VBA code is:

SUB GetSelectedValues()

     

'       set export = ActiveDocument.Variables("mensal")        

      

       If export = "0" then

      

           MsgBox "aaa"

          

       Else

               MsgBox "bbb"

              

       End If

      

END SUB

But with this code I get a problem on the IF.

Can anyone help?

Thank you in advance.

Ivo Marques

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

SUB GetSelectedValues

   

export =ActiveDocument.GetVariable("mensal").GetContent.String

    

       If export = "0" then

    

           MsgBox "aaa"

        

       Else

               MsgBox "bbb"

            

       End If

    

END SUB

Thanks

BKC

View solution in original post

3 Replies
Anonymous
Not applicable
Author

SUB GetSelectedValues

   

export =ActiveDocument.GetVariable("mensal").GetContent.String

    

       If export = "0" then

    

           MsgBox "aaa"

        

       Else

               MsgBox "bbb"

            

       End If

    

END SUB

Thanks

BKC

Not applicable
Author

Hi Ivo

export = ActiveDocument.Variables("mensal").GetContent.String

should work for you

Joe      

Not applicable
Author

It works.

Thank you guys