0 Replies Latest reply: Jul 9, 2013 5:52 AM by Richard Beeston RSS

    Exporting to Excel and Selection Issues

      I'm trying to automate export a table to multiple excel worksheets. In each sheet is a different selection collection.


      The issue I have encountered is that intially I want to select all customers that start with "ABC" (which is straightforward) but then select all customers not starting with "ABC" and export these to the next excel worksheet.


      I tried this line in the macro but it does not appear to behave in the same way as manually using select excluded in the application -



      Is there any way to write a line in the macro that would select all "CustomerName"s not beginning with "ABC"?



      sub ReportExport
      set XLApp = CreateObject("Excel.Application")
      XLApp.Visible = false
      set XLDoc = XLApp.Workbooks.Add
      'Bring total of sheets upto 4
      XLDoc.Sheets(1).Name = "Report1"
      ActiveDocument.GetSheetObject("CH162").CopyTableToClipboard true
      XLApp.Visible = true
      Set C=ActiveDocument.Getfield("ChannelName")
      C.Select "Channel1"
      ActiveDocument.GetField("CustomerName").SelectExcluded ' Does not appear to work as it would in the application
       'Export Report to next sheet etc
       msgbox "Done"
      end sub