5 Replies Latest reply: Jul 24, 2017 6:10 AM by Christine Robinson RSS

    Keeping Leading Zero in Export

    Christine Robinson



      Trying to export customer number from a table into excel.  If use the XL button they remain as text but if I use a macro these turn to a number and drop the leading zero.  If was only 1 table I would use the XL button but there is 20 tables and is time consuming.


      Has anyone any ideas on what I can add to the macro to keep table as text?


      Thank you for help in advance


      sub export_whole_customer_list


      set XLApp = CreateObject("Excel.Application")

      XLApp.Visible = True

      set XLDoc = XLApp.Workbooks.Add




      Set xlSheet = xlDoc.Worksheets("Sheet1")


      set obj = ActiveDocument.getsheetobject("CH199")

      obj.CopyTableToClipboard true



      XLApp.Sheets("Sheet1").Name = "customer"


      end sub


      Customer NoCustomer NameEmailTelephone1Telephone 2Total SaleTotal Qty
      12345Mrs Happyhappy@test.com012345678990781234123420020
      65478Mr Grumpygrumpy@test.com021365498740789874632180050