Re: Excel 2011: Select noncontiguous columns
Re: Excel 2011: Select noncontiguous columns
- Subject: Re: Excel 2011: Select noncontiguous columns
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 20 Oct 2011 02:21:48 -0700
- Thread-topic: Excel 2011: Select noncontiguous columns
--
Paul Berkowitz
> From: David Wignall <email@hidden>
> Date: Thu, 20 Oct 2011 22:15:07 +1300
> To: AppleScript-Users <email@hidden>
> Subject: Re: Excel 2011: Select noncontiguous columns
>
>
> On 20 Oct 2011, at 9:27 PM, Paul Berkowitz wrote:
>
>> On 10/20/11 12:25 AM, "Olivier Berquin" <email@hidden> wrote:
>>
>>>
>>> I really donĀ¹t understand what is happening.
>>
>> It's a built-in limitation, but not a bug.
>>
>> You're supposed to be able to do almost exactly what you wanted, this way:
>>
>> tell application "Microsoft Excel"
>> tell active sheet
>> set myRange to union range1 column 6 range2 column 8 range3 column
>> 11 range4 column 11 range5 column 14 range6 column 17
>> end tell
>> myRange
>> set bold of font object of myRange to true
>> --set width of myRange to 14 --?
>> end tell
>>
>>
>> It (the 'union' command does) works as far as creating and getting myRange,
>> and it will also set the font of the whole range to bold. That's because
>> myRange is a range, and a range can have a single font object, whose
>> properties, like bold, can be set. But a range does not have a 'column
>> width', only a total width, which makes no sense for a range of
>> non-contiguous columns. The same applies even if you refer to it as range
>> "F:F,H:H,K:K,N:N,Q:Q", as you found.
>
> Respectfully Paul, I must disagree. The script Oliver posted
>
>> tell application "Microsoft Excel"
>> tell active workbook
>> tell active sheet
>> set myRange to column ("F:G,I:J")
>> set column width of myRange to 5
>> end tell
>> end tell
>> end tell
>
> works perfectly well. What also works is
>
> tell application "Microsoft Excel"
> set rng to range ("F:F,H:H,J:J,L:L")
> set column width of rng to 14
> end tell
>
> (FWIW, conceptually it's identical to what you would write in VBA).
>
> A range object does have a column width. It is the width of each column that
> comprises the range. As the range object must have at least one cell you can
> in fact say
>
> tell application "Microsoft Excel"
> set rng to range ("A1")
> set column width of rng to 26
> end tell
>
> I sent Oliver my solution off list (unintentionally - that whole 'reply not to
> list' thing that happens here) yet for some reason they did not work for him.
> I have no idea why; these scripts I have tested with Excel 2011 and Excel 2008
> using both Smile and AppleScript Editor. The only time they error is if Excel
> 2011 is not open when the script runs, in which case XL reaches the Workbook
> Gallery and stops thus no workbook is open.
>
> --
> 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
_______________________________________________
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