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 -
ActiveDocument.GetField("CustomerName").SelectExcluded
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.Worksheets.Add()
XLDoc.Sheets(1).Name = "Report1"
ActiveDocument.GetSheetObject("CH162").CopyTableToClipboard true
XLDoc.Sheets(1).Paste()
XLDoc.Sheets(1).Rows("1:5000").EntireRow.AutoFit
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