ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Automation problem with AutoFilters (https://www.excelbanter.com/excel-programming/360393-excel-automation-problem-autofilters.html)

Nexus

Excel Automation problem with AutoFilters
 
I've developed a VB application that does some OLE Automation using Excel.

I want to check that there is no autofilter currently active and that all
rows are shown (but still keep the AutoFilter enabled).

The code to this is within a VBA macro is

Activesheet.ShowAllData

(I believe)

However when I try to do this within VB e.g

Dim X as New Excel.Application
.......
X.ActiveSheet.ShowAllData

I get object does not support method.

Any ideas what I am doing wrong?



Jim Cone

Excel Automation problem with AutoFilters
 
My guess is that the application is not visible, so nothing is active.
It is best when automating Excel to set object references
to all Excel objects and avoid the use of "Active...".
Try something like this...

Dim xlApp As Excel.Application
Dim WB As Excel.Workbook
Dim WS As Excel.Worksheet

Set xlApp = New Excel.Application
Set WB = xlApp.Workbooks.Add
Set WS = WB.Sheets(1)
'other stuff
WS.ShowAllData

Make sure to set all object variables to Nothing
when exiting Excel.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Nexus"
wrote in message
I've developed a VB application that does some OLE Automation using Excel.

I want to check that there is no autofilter currently active and that all
rows are shown (but still keep the AutoFilter enabled).
The code to this is within a VBA macro is
Activesheet.ShowAllData
(I believe)

However when I try to do this within VB e.g

Dim X as New Excel.Application
.......
X.ActiveSheet.ShowAllData

I get object does not support method.
Any ideas what I am doing wrong?




All times are GMT +1. The time now is 06:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com