3 Replies Latest reply: May 14, 2015 12:27 PM by ekta rathi RSS

    Leading zeroes are dropped while exporting to excel using macro

    ekta rathi

      Hi All,


      I am using below mentioned macro to export 2 objects to excel using a button.My data exports to excel fine, but when I look at some fields like emplid, location cd etc, the leading zeroes are dropped. Could someone please help me with this?    


      sub ExcelFile

      Path = "C:\temp\"
      FileName = "Test_" & GetFormattedDate  & ".xlsx"

      set XLApp = CreateObject("Excel.Application")

      XLApp.Visible = true
      set XLDoc = XLApp.Workbooks.Add

      ActiveDocument.GetSheetObject("CH04").CopyTableToClipboard true


      ActiveDocument.GetSheetObject("CH01").CopyTableToClipboard true


      'ActiveDocument.GetSheetObject("CH24").CopyTableToClipboard true


      XLDoc.Sheets(1).Name = "Page One"
      XLDoc.Sheets(2).Name = "Page Two"
      'XLDoc.Sheets(3).Name = "Page Three"

      end sub