Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
rygreene3
Contributor II
Contributor II

Inserting a variable value using ActiveDocument.fields in a macro

Hello.  

I currently use the following command in my macro to filter on a specific value before exporting data into a QVD.  I have to repeat this operation across multiple fields using the same value.  I would like to use an Input Object to set the search value as a variable, and then insert that variable value into the ActiveDocument.fields command.  Can someone show me how I would do that?

Here's my current command:   ActiveDocument.fields("CREG_GLOBAL_ULTIMATE_ID").Select("23471")

The variable name associated to the Input Object is, "vZONE_CR_GU_VARIABLE"

I thought I could do the following command, but it isn't working.  I think I must be missing a step:  ActiveDocument.fields("CREG_GLOBAL_ULTIMATE_ID").Select("vZONE_CR_GU_VARIABLE")

Thank you!

2 Solutions

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Here are two ways to get the contents of a variable using VBScript. 

varValue = ActiveDocument.GetVariable("vZONE_CR_GU_VARIABLE").GetContent.String

varValue = ActiveDocument.Evaluate("'$(vZONE_CR_GU_VARIABLE)'")

And then you can use like:

ActiveDocument.fields("CREG_GLOBAL_ULTIMATE_ID").Select(varValue)

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

 

View solution in original post

rygreene3
Contributor II
Contributor II
Author

You are the MAN!  Thank you so much, Rob.  It worked exactly as you described.  This will save me a ton of time... you're my hero.

 

View solution in original post

2 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Here are two ways to get the contents of a variable using VBScript. 

varValue = ActiveDocument.GetVariable("vZONE_CR_GU_VARIABLE").GetContent.String

varValue = ActiveDocument.Evaluate("'$(vZONE_CR_GU_VARIABLE)'")

And then you can use like:

ActiveDocument.fields("CREG_GLOBAL_ULTIMATE_ID").Select(varValue)

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

 

rygreene3
Contributor II
Contributor II
Author

You are the MAN!  Thank you so much, Rob.  It worked exactly as you described.  This will save me a ton of time... you're my hero.