Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
souadouert
Specialist
Specialist

EXpression variable

Hello,

how to have all the list of the variables of an application with its expression, without going through the menu of the variables

1 Solution

Accepted Solutions
arvind1494
Specialist
Specialist

Create an empty Inputbox object and note the object reference.

Create this macro subroutine ...

sub ShowVars

    rem ** Show name of all variables in document **

    set vars = ActiveDocument.GetVariableDescriptions

    set IB = ActiveDocument.GetSheetObject("IB01")

    for i = 0 to vars.Count - 1

        set v = vars.Item(i)

        'msgbox(v.Name & "=" & v.RawValue)

      

        'Add to InputBox object (IB01)

        IB.AddVariable v.Name

    next

end sub

Add a button to call this code

View solution in original post

12 Replies
arvind1494
Specialist
Specialist

Create an empty Inputbox object and note the object reference.

Create this macro subroutine ...

sub ShowVars

    rem ** Show name of all variables in document **

    set vars = ActiveDocument.GetVariableDescriptions

    set IB = ActiveDocument.GetSheetObject("IB01")

    for i = 0 to vars.Count - 1

        set v = vars.Item(i)

        'msgbox(v.Name & "=" & v.RawValue)

      

        'Add to InputBox object (IB01)

        IB.AddVariable v.Name

    next

end sub

Add a button to call this code

souadouert
Specialist
Specialist
Author

Thank ypu

arvind1494
Specialist
Specialist

Welcome

souadouert
Specialist
Specialist
Author

Arvid how to write the value in csv or text file ?

arvind1494
Specialist
Specialist

Souad try this

1. Create an input box

2. Click Add All to list all variables

3. Send to Excel

souadouert
Specialist
Specialist
Author

i used this script

sub ShowVars



    rem ** Show name of all variables in document **


    set vars = ActiveDocument.GetVariableDescriptions


    set IB = ActiveDocument.GetSheetObject("IB01")

   

       DIM fso, MyFile, strFile, strText

    strFile="c:\temp\link.msgFile"  

Set fso = CreateObject("Scripting.FileSystemObject")

    for i = 0 to vars.Count - 1


        set v = vars.Item(i)


        'msgbox(v.Name & "=" & v.RawValue)


     


        'Add to InputBox object (IB01)


       link=v.Name &","&v.RawValue

       

       

       

          If fso.FileExists(strFile) Then

       Set MyFile = fso.OpenTextFile (strFile, 2, True)

    Else

        Set MyFile = fso.CreateTextFile(strFile)

    End If

      MyFile.WriteLine(link)

      OpenFile()

    MyFile.Close


    next



   

 


end sub

FUNCTION OpenFile

set app = ActiveDocument.GetApplication

app.Launch "C:\temp\link.msgFile", "file path"

END FUNCTION

But i have always problem with this ligne

       link=     link=v.Name &","&v.RawValue

arvind1494
Specialist
Specialist

Please run the code which i had given above and make sure that reference of empty input box is correct

and let me know its working or not

souadouert
Specialist
Specialist
Author

I modified the script

sub ShowVars



    rem ** Show name of all variables in document **


    set vars = ActiveDocument.GetVariableDescriptions


   

   

       DIM fso, MyFile, strFile, strText

    strFile="C:\Prod\liste"  

Set fso = CreateObject("Scripting.FileSystemObject")

    for i = 0 to vars.Count - 1


        set v = vars.Item(i)


        'msgbox(v.Name & "=" & v.RawValue)


     


        'Add to InputBox object (IB01)


       link= v.Name &","&v.RawValue

       

       

       

          If fso.FileExists(strFile) Then

       Set MyFile = fso.OpenTextFile (strFile, 2, True)

    Else

        Set MyFile = fso.CreateTextFile(strFile)

    End If

      MyFile.WriteLine(link)

      OpenFile()

    MyFile.Close


    next



   

 


end sub

FUNCTION OpenFile

set app = ActiveDocument.GetApplication

app.Launch "C:\Prod\liste", "file path"

END FUNCTION


the script executed but the file is empty

arvind1494
Specialist
Specialist

It is because of macro security issues