Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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..
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
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