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

Macro to Export a field from a table into a .txt file from Qlikview document

Hi All,

I was trying to find a Macro example to Export field from a table into a  .txt file from Qlikview document when the Qlikview document resides in the accesspoint.

I can save a .txt file in my local machine using the below macro But dont know how it works when the Document is deplyed to production. How the users can press a button and it will prompt to download a text file based on the selection of the users? Is it possible to achieve?

Sub Export

ActiveDocument.Sheets("SH02").Activate

set obj = ActiveDocument.GetSheetObject("TB02")

filepath="C:\test\test.txt" 

obj.Export filepath,4

ActiveDocument.GetApplication.Sleep 5000

End Sub

Can anyone help me with this?

Thanks,

Ahmed

1 Solution

Accepted Solutions
marcus_sommer

Within the actions by extern is an export-possibilty from selectable fields (not objects but by a tablebox there are only fields, too) into a txt-file.

- Marcus

View solution in original post

5 Replies
robert_mika
Master III
Master III

This macro will loop thru objects in Sheet "Main" and will send object with Caption Name specified by userinput

Sub Export

set s=ActiveDocument.Sheets("Main")

name = ActiveDocument.GetApplication.InputBox("Enter name of the object?")

Objects = ActiveDocument.ActiveSheet.GetSheetObjects

    For j = lBound(Objects) To uBound(Objects)

        set obj = Objects(j)

IF obj.GetCaption.Name.v = name Then

filepath="C:\test\"&name&".txt"

obj.Export filepath,4

else

end if

next

End Sub

You can add listbox with objects in the sheet so user knows names of the objects.

make sure that all objects have caption name

2015-05-03 08_16_38-QlikView Personal Edition - [C__Users_Katarzyna_Desktop_Export.qvw_].png

AH
Creator III
Creator III
Author

Hi Mika,

Thanks for your nice feedback. I can get a text file in my local machine with piece of code i have already mentioned. My problem is, when i press the web mode on it doesnt work. What i mean is, If i deploy the Dashboard in production, will the macro going to work in the accesspoint? Is it going to prompt a download option of the specified object in text file?

Thanks again.

Ahmed

robert_mika
Master III
Master III

Look at this topic

Macros are not working in accesspoint(IIS)

Give a try and you will see.

marcus_sommer

Within the actions by extern is an export-possibilty from selectable fields (not objects but by a tablebox there are only fields, too) into a txt-file.

- Marcus

AH
Creator III
Creator III
Author

Marcus,

Although I wanted to have some kind of prompt to download the Field in a text file But your solution still do the trick for me.

Excellent!

Thank you so much.

Ahmed