VBA to Control Excel from Visio

Started by leweyb, February 21, 2018, 02:09:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

leweyb

Hello,

I'm try to use VBA from Visio to select an already opened Excel worksheet and filter a table; the code I have is below.


Dim xlApp As Object
Dim xlWB As Object
Dim xlWS As Object

Set xlApp = GetObject(, "Excel.Application")
Set xlWB = xlApp.Workbooks("Example")
Set xlWS = xlWB.Worksheets("Example1")

xlApp.Visible = True
xlApp.ScreenUpdating = True

xlWS.ListObjects("Table2").Range.AutoFilter Field:=1, Criteria1:=Array("1069", "1070", "1091" etc. etc.), Operator:=xlFilterValues

Set xlApp = Nothing
Set xlWB = Nothing
Set xlWS = Nothing


With this code the worksheet is selected, but no filtering happens! As soon as I remove the "Operator:=xlFilterValues" from the code, it works but It only filters the last number in the series, however I need all the numbers to be selected for filtering.

Any help much appreciated!