Re: Excel: hide multiple columns with Applescript
Re: Excel: hide multiple columns with Applescript
- Subject: Re: Excel: hide multiple columns with Applescript
- From: Cameron Knowlton <email@hidden>
- Date: Sat, 16 Apr 2011 12:35:41 -0700
Title: Re: Excel: hide multiple columns with
Applescript
Wow, disabling screen updating DID speed things up
considerably:
local
pivotItemCount
tell application "Microsoft Excel"
set currentDoc
to active workbook
set
currentSheet to active sheet
of currentDoc
set
pivotTable to pivot table "myPivotTable"
of currentSheet
set
pivotItemCount to count of pivot items of
pivot field "Date" of
pivotTable
set
screen updating to false
tell
pivotTable
-- this works, but is
slow (VERY slow with screen updating
enabled, but not bad with it disabled)
set
pivotHideCount to (pivotItemCount -
5) -- number of columns to hide,
beginning from the left (oldest)
repeat with pivotIndex
from 1
to pivotHideCount
set
visible of pivot item pivotIndex of pivot
field "Date" to 0
end repeat
end tell
set
screen updating to true
end tell
At 10:22 AM -0700 11/03/21, Paul Berkowitz wrote:
On 3/21/11 2:21 AM, "David Wignall"
<email@hidden> wrote:
> All of which works but when I tested with a different field, one
with 89 items
> it took a noticeable time, complete with SPOD but less than 1
minute, to
> create the list of names. However it took no real time at all to
hide all
> those fields, so if you already know the names then that's
irrelevant.
> (Errored on the last one because at least 1 field must be
visible).
Sometimes, if you 'set screen updating to
false' before beginning such an
operation via AppleScript, then setting it back to true when done, you
can
save a lot of time and speed it up. Does that help in this
circumstance?
('screen updating' is a property of the application, so should be done
in a
tell app "Microsoft Excel" block without any internal tell
blocks around
it.)
--
Paul Berkowitz
--
Cameron Knowlton
KnowledgeVine SEO Dashboards
email@hidden
P: 250.382.0226
http://www.knowledgevine.net
_______________________________________________
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