Re: Excel: hide multiple columns with Applescript
Re: Excel: hide multiple columns with Applescript
- Subject: Re: Excel: hide multiple columns with Applescript
- From: David Wignall <email@hidden>
- Date: Mon, 21 Mar 2011 12:07:04 +1300
Resend, this time to the list <sigh />
On 21 Mar 2011, at 7:02 AM, Cameron Knowlton wrote:
> Thanks, David, that was insightful; I wouldn't have though to use a column range. Unfortunately, that doesn't quite do it:
>
> set entireColumns to entire column of pivotColumns
> set hidden of entireColumns to true
>
> I'm not trying to hide *spreadsheet columns*, I'm trying to made *pivot columns* not visible.
Ah, with you now.
set Pivot_Table to pivot table 1 of active sheet
--> pivot table 1 of active sheet
name of column fields of Pivot_Table
--> {"Salesperson", "Product Name"}
set Pivot_Field to pivot field "Salesperson" of Pivot_Table
--> pivot field "Salesperson" of pivot table 1 of active sheet
set pivot field orientation of Pivot_Field to orient as hidden
A couple of extra comments from the message that went directly to Cameron:
> set entirePivotItems to pivot items of pivot field "Date"
This works for me but the field I'm testing on has only 8 items so that may be a factor
> set pivotTable to pivot table "myPivotTable" of currentSheet
> tell pivotTable
> set hidden of entire column of range ("$D:$J") to true
> end tell
Was currentSheet set to the correct worksheet beforehand? The error
-- Microsoft Excel got an error: The object you are trying to access does not exist
indicates that the pivot table is either not on currentSheet or not named "myPivotTable" (or both)
On Mon, Mar 21, 2011 at 09:14, Paul Berkowitz <email@hidden> wrote:
> [...] That sometimes helps (and probably also explains
> why David used so many lines, setting just one property per line).
Yep :-). That, and it makes it easier to test different properties in a Smile terminal window, and it might give a clue for another problem to someone else reading the archives. When one remembers to address one's reply to the list...
As an aside, a close reading of XL's AppleScript dictionary entry for pivot field -> pivot field orientation does show orient as hidden but in this case I knew it previously from Win-Office and VBA. The joys of recordability, don't you know.
--
Dave _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden