3 Replies Latest reply: Feb 19, 2016 3:54 AM by Marcello Aondio RSS

    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 :



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

      Thanks Everybody!


        • Re: Create / export   .txt file from button
          Settu Periyasasamy


          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")
                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")
                obj.Export filename,","
          end sub


          Check the Attachment..

          • Re: Create / export   .txt file from button
            Jonathan Dienst

            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)


              • Re: Create / export   .txt file from button

                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