1 Reply Latest reply: Feb 10, 2014 3:25 PM by Aderlan Rodrigues RSS

    Macro to export a .csv and zip it

    Vamshi Tataipelli



      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.