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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Create / export .txt file from button

Hi Everybody,

how can i create an empty .txt file from my dashboard with a button?

I need to create on my desktop an empty .txt file with this naming convention :

XX_YY_GG-MM-AAAA_HH-MM-SS.txt


where GG-MM-AAAA_HH-MM-SS represent the now().


Thanks Everybody!

M



Labels (1)
3 Replies
settu_periasamy
Master III
Master III

Hi,

May be this macro will help...

Create one field without value and use it as a ListBox, (Here the object ID LB01) .

Create one Button, Assign the below Macro

sub Test()

      set obj = ActiveDocument.GetSheetObject("LB01")

          path=ActiveDocument.Evaluate("=Replace(DocumentPath(),subfield(DocumentPath(),'\',-1),'')")

          fname=ActiveDocument.Evaluate("=Timestamp(now(),'DD-MM-YYYYY_hh-mm-ss')")

      obj.Export path&"\XX_YY_"&fname&".txt",","

end sub

Or, You can create two variables, and use it in your macro.. Like

sub Test_1()

      set obj = ActiveDocument.GetSheetObject("LB01")

      set path=ActiveDocument.GetVariable("vPath")

      set fname=ActiveDocument.GetVariable("vFile")

      filename=path.getcontent.string&"XX_YY"&fname.getcontent.string&".txt"

      obj.Export filename,","

end sub

Check the Attachment..

jonathandienst
Partner - Champion III
Partner - Champion III

You don't need to export a dummy object, rather use the vbscript fso api:

fname = "\XX_YY_" & ActiveDocument.Evaluate("=Timestamp(now(),'DD-MM-YYYYY_hh-mm-ss')") & ".txt"

Set filesys = CreateObject("Scripting.FileSystemObject")

Set filetxt = filesys.CreateTextFile(fname, True)

filetxt.Close

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thanks Jonathan,

finally i've used this macro:

sub EXPORT()

dim a
a = now()

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\Users\marcello.aondio\Desktop\Sorgenia 2\" & "TASK_NOMETASKAA_UTENTEQV_" & left(a,2) & "-" & Right(Left(a, 5), 2) & "-" & Right(Left(a, 10), 4) & "_" &Right(Left(a, 13), 2)& "-" &Right(Left(a, 16), 2)& "-" &Right(Left(a, 19), 2)& ".txt")

end sub