newholyman
asked on
MS access vba turn of filter in Excel worksheet
From Ms access using VBA turn off filter in MS Excel sheet. Some time user leave the filter turn on in Excel sheet. This cause the import to fail.
Ms Acess 2010
Excel 2010
I need to turn the filter off in the Excel sheet using VBA from Ms Access.
Thank you
Ms Acess 2010
Excel 2010
I need to turn the filter off in the Excel sheet using VBA from Ms Access.
Thank you
ASKER
received error message object does not support this object or method
Dim xlObj As Object, Sheet As Object
Dim xlFile As String
xlFile = ("file")
Rem xlFile = wrk_copy
Set xlObj = CreateObject("Excel.Applic ation")
xlObj.Workbooks.Open xlFile
xlObj.Visible = True
Set Sheet = xlObj.ActiveWorkbook.Works heets("she etname")
If xlObj.AutoFilterMode = True Then xlObj.AutoFilterMode = False
xlObj.ActiveWorkbook.Save
xlObj.ActiveWorkbook.Close
Dim xlObj As Object, Sheet As Object
Dim xlFile As String
xlFile = ("file")
Rem xlFile = wrk_copy
Set xlObj = CreateObject("Excel.Applic
xlObj.Workbooks.Open xlFile
xlObj.Visible = True
Set Sheet = xlObj.ActiveWorkbook.Works
If xlObj.AutoFilterMode = True Then xlObj.AutoFilterMode = False
xlObj.ActiveWorkbook.Save
xlObj.ActiveWorkbook.Close
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Here the final vba that worked;
Dim xlObj As Object, Sheet As Object
Dim xlFile As String
xlFile = ("file")
Rem xlFile = wrk_copy
Set xlObj = CreateObject("Excel.Applic ation")
xlObj.Workbooks.Open xlFile
xlObj.Visible = True
Set Sheet = xlObj.ActiveWorkbook.Works heets("she etname")
If Sheet.AutoFilterMode = True Then Sheet.AutoFilterMode = False
xlObj.ActiveWorkbook.Save
Thank you
Dim xlObj As Object, Sheet As Object
Dim xlFile As String
xlFile = ("file")
Rem xlFile = wrk_copy
Set xlObj = CreateObject("Excel.Applic
xlObj.Workbooks.Open xlFile
xlObj.Visible = True
Set Sheet = xlObj.ActiveWorkbook.Works
If Sheet.AutoFilterMode = True Then Sheet.AutoFilterMode = False
xlObj.ActiveWorkbook.Save
Thank you
If the suggestion I posted did the trick (If Sheet.AutoFilterMode = True Then Sheet.AutoFilterMode = False), why did you award a B grade?
EE's grading standards are here:
http://support.experts-exchange.com/customer/portal/articles/481419-what-grade-should-i-award-?b_id=44
EE's grading standards are here:
http://support.experts-exchange.com/customer/portal/articles/481419-what-grade-should-i-award-?b_id=44
A B grade means the solution given lacked some information or required you to do a good amount of extra work to resolve the problem. When closing the question, the asker should explain why a B grade was awarded.
xlWS.AutoFilterMode = False
if you are not currently using automation, it is done similar to this:
Open in new window