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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Macro to export a .csv and zip it

Hi,

I have very little knowledge on vb script. I am using the below vb script to export a sheet object to a .csv file.

sub Export

Dim docProp

set docProp = ActiveDocument.GetProperties

Dim tmpFile  'used to create relative filepaths

tmpFile = docProp.MyWorkingDirectory

Dim vSpl  'location of final backslash char

vSpl = InStrRev(tmpFile,"\")

tmpFile = Left(tmpFile,vSpl-1)

vSpl = InStrRev(tmpFile,"\")

tmpFile = Left(tmpFile,vSpl) & "External Data Sources\OperationalReportsOutput\BankruptcyRptSpreadsheet_" & DatePart("YYYY", Now()) & right( "0" & DatePart("m", Now()) ,2) & right( "0" & DatePart("d", Now()) ,2) & ".csv"    

set obj = ActiveDocument.GetSheetObject("CH02")

obj.ExportBiff tmpFile

But, the file forming is more than 25mb and it was not getting attached to the mail and am unable to send the email. So, i need the script to create a zip folder and compress the file. How can i do it. Please help me with your suggestion.

1 Reply
aderlanrm
Partner - Specialist
Partner - Specialist

Hi Vamshi,

Sorry the ingles bad.

I don't know with macro, but with script I suggest.

STORE Sample into c:\Temp\Malling.csv (txt, delimiter is ';');

EXECUTE cmd.exe /C c:\WinRAR.exe a -afzip -df c:\Temp\Sample.zip c:\Temp\Malling.csv;

EXECUTE cmd.exe /C del /f/q c:\Temp\Malling.csv;

Bye.

Aderlan Rodrigues
Analista, Arquiteto de Dadose e Desenvolvedor
 (41) 9 9917-0869  www.BIdeAZ.com.br  Youtube.com/bideaz  Instagram.com/bideaz.in

"Nada é tão inútil quanto fazer eficientemente o que não deveria ser feito." (Peter Drucker)