Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Assign a variable from a text box

Hi Qlikviewers! It's possible that this may require a macro, which I am open to doing (though would prefer not to), but I am wondering how I might go about assigning a variable based on the content of a text box. I would like to have a variable that is equal to whatever text is in a certain text box.

I've attached an example app.

Here's the macro I made:

sub GetTextBoxValue()

set obj1 = ActiveDocument.GetSheetObject("TX02")

set txtbx = obj1.getTextValue

set txtbx = ActiveDocument.Variables("vTextBox")

end sub

1 Solution

Accepted Solutions
Not applicable
Author

Well I figured it out with a macro after a couple hours of trial and error.


See attached.

The macro you need is

sub CommentVars

set dotextbox = ActiveDocument.GetSheetObject( "TX02" )

set dovartext = ActiveDocument.Variables("vTextBox")

for RowIter = 0 to dotextbox.GetRowCount-1

    for ColIter =0 to dotextbox.GetColumnCount-1

        set cell1 = dotextbox.GetCell(RowIter,ColIter)

        dovartext.SetContent cell1.Text, TRUE

    next

next

end sub

View solution in original post

4 Replies
Not applicable
Author

I should add that the goal here is not to transfer text from one box to another, but to actually get the variable assigned

Not applicable
Author

Well I figured it out with a macro after a couple hours of trial and error.


See attached.

The macro you need is

sub CommentVars

set dotextbox = ActiveDocument.GetSheetObject( "TX02" )

set dovartext = ActiveDocument.Variables("vTextBox")

for RowIter = 0 to dotextbox.GetRowCount-1

    for ColIter =0 to dotextbox.GetColumnCount-1

        set cell1 = dotextbox.GetCell(RowIter,ColIter)

        dovartext.SetContent cell1.Text, TRUE

    next

next

end sub

awhitfield
Partner - Champion
Partner - Champion

HI Jesse,

why not try using a input box to set the variable value instead? Check out the QV help file for further information

HTH Andy

Not applicable
Author

That's a much more elegant solution. Unfortunately, there's two things preventing this

- The text box has formatting that needs to be displayed in the QVW and transfered to the variable (ie newlines)

- The text box content is different depending on a filter selection