Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Enable AutoFilter on Excel protected sheet using OLE2_OBJECT

prince_isaac
Active Participant
0 Likes
1,815

Hi guys

I have created my excel sheet using OLE2_OBJECT and managed to protect the sheet and format columns as required however now i need to have AutoFilter on two columns on the sheet.  I am only managing to have one column at a time showing the AutoFilter and i can only have this AutoFilter usable/enabled if the password protection is off.  I have done some research and discovered that using VBA coding this is possible as detailed in this link: http://office.microsoft.com/en-za/excel-help/enable-autofilter-functionality-for-a-protected-workshe...

I have done my coding for the column formating like this:

call method of lw_excel 'Columns' = lw_columns

       exporting

         #1 = 9.

     set property of lw_columns 'AutoFilter' = 1.


call method of lw_excel 'Columns' = lw_columns

       exporting

         #1 = 10.

     set property of lw_columns 'AutoFilter' = 1.

This however is not working on column 10.  How can i enable the AutoFilter on both column 9 and 10 and still have the sheet password protected.

regards

PrinceIsaac

Hi guys

I have created my excel sheet using OLE2_OBJECT and managed to protect the sheet and format columns as required however now i need to have AutoFilter on two columns on the sheet.  I am only managing to have one column at a time showing the AutoFilter and i can only have this AutoFilter usable/enabled if the password protection is off.  I have done some research and discovered that using VBA coding this is possible as detailed in this link: http://office.microsoft.com/en-za/excel-help/enable-autofilter-functionality-for-a-protected-workshe...

I have done my coding for the column formating like this:

call method of lw_excel 'Columns' = lw_columns

       exporting

         #1 = 9.

     set property of lw_columns 'AutoFilter' = 1.


call method of lw_excel 'Columns' = lw_columns

       exporting

         #1 = 10.

     set property of lw_columns 'AutoFilter' = 1.

This however is not working on column 10.  How can i enable the AutoFilter on both column 9 and 10 and still have the sheet password protected.

regards

PrinceIsaac

7 REPLIES 7
Read only

prince_isaac
Active Participant
0 Likes
1,358

Hi guys

I accidentaly clicked Answered.  I am no way near solving the issue as of now.

regards

Prince Isaac

Read only

0 Likes
1,358

Hi Prince,

Can you Provide your Complete Code .

Regard's

Smruti

Read only

0 Likes
1,358

Can you check this Methods/ Properties.....

Methods
NameDescription
ApplyFilterApplies the specified Autofilter object.
ShowAllDataDisplays all the data returned by the AutoFilter object.

Properties
NameDescription
ApplicationWhen used without an object qualifier, this property returns an Application object that represents t...
CreatorReturns a 32-bit integer that indicates the application in which this object was created. Read-only Long.
FilterModeReturns True if the worksheet is in the AutoFilter filter mode. Read-only Boolean.
FiltersReturns a Filters collection that represents all the filters in an autofiltered range. Read-only.
ParentReturns the parent object for the specified object. Read-only.
RangeReturns a Range object that represents the range to which the specified AutoFilter applies.
SortGets the sort column or columns, and sort order for the AutoFilter collection.


Regard's

Smruti

Read only

0 Likes
1,358

Hi Smruti

I am unable to get two columns on my sheet to have the AutoFilter set.  The code i sent above correctly sets the AutoFilter on the 9th column but not on the 10th.  The properties/methods you mentioned are exactly what i am trying to understand how i can use to achieve my goal.

regards

Prince Isaac

Read only

0 Likes
1,358

Hi Prince ,

Check this Sample code for Auto filter set for 9th and 10th Column .

CALL METHOD OF H_EXCEL 'Cells' = GS_CELL1

     EXPORTING

     #1 = 1                                   " 1st Row

    #2 = 9.                                   " 9 th Column

   CALL METHOD OF H_EXCEL 'Cells' = GS_CELL2

     EXPORTING

     #1 = 1                                  "  1st Row

     #2 = 10.                               " 10th Column

   CALL METHOD OF H_EXCEL 'Range' = GS_CELLS

     EXPORTING

     #1 = GS_CELL1

     #2 = GS_CELL2.

   CALL METHOD OF GS_CELLS 'Select' .

SET PROPERTY OF GS_CELLS 'AutoFilter' = 1.

Regard's

Smruti

Read only

0 Likes
1,358

Hi Smruti

I tried the above suggestion and it did not work for me.  It actually distorted the output file by moving the data 9 columns to the right.  I tried changing around the coding but no luck.

regards

Read only

0 Likes
1,358

Can you Share your Complete Code .

with some sample input and output what actually you want .

Regard's

Smruti