Interesting indeed Paul (Hi at you too!),
I have known of this bug in convert to table for some time, but I don't believe i ever went delving into the UI settings in this way.
It seems reasonable that the UI should 'remember' the value set under 'other', even though it is not selected. I can even picture some pro developer pointing his code at that value without realising that the 'standard' values for separator override the Other setting. The 'stickiness' of the tabs setting and the confusion of the underlying applescript/VBA implementation do appear to suggest a deep seated bug here.
Will it ever get fixed? Given that, historically, applescript bugs have had a low priority I wouldn't hold my breath, especially when there is an easy work-round. However, the fact that the same bug is exhibited in VBA ives me a little hope (but not much). Out of interest (and to save me the trouble of launching boot camp) - is the same bug exhibited in VBA in Word for Windows?
On 15 Nov 2012, at 00:17, Paul Berkowitz < email@hidden> wrote:
Interesting. (Hi, Barry!) When I query Word via AS:
tell application "Microsoft Word"
get default table separator
end tell
"-"
the result is a dash (hyphen). But when I do so in the UI, by selecting the same text, going to Table/Convert/Convert Text to Table..., I get a dialog box that has Separate text at: set to Tabs by default. ("-" shows up preset as the "Other" option not taken.) It's highly unusual to have an AS (or VBA) option different than the one that exists in the UI.
If I go into the UI, and set the Separate text at: Other and change "-" to something else, like "—", then running the script above now gets me "—", as you'd think it would. But then when I go back into the UI, it's now showing the
Separate text at: back to Tabs! Even though "—" does show up as the unchosen Other option.
Basically, at the automation level, the default table separator is actually whatever the UI shows for "Other" option, even though that Other option may not be chosen (and in fact reverts back to Tabs at the very next Convert operation). The bugginess goes deeper than the script level, and the script is probably responding with an Error when you try to set the separator parameter because it's never been connected up to the UI, which in turn has a deeper predilection for Tabs as a default default but doesn't translate any of that to the automation model. Highly weird.
--
Paul Berkowitz
From: Barry Wainwright <email@hidden>
Date: Wed, 14 Nov 2012 22:13:54 +0000
To: AppleScript-Users <email@hidden>
Subject: Re: Table in Word 2012
Unfortunately the 'separator' option in convert to table is broken.
This ugly hack works though:
tell application "Microsoft Word"
set txt to selection's text object
set default table separator to tab
set theResult to convert to table txt
end tell
--
Barry
On 14 Nov 2012, at 11:11, Jeremy Roussak <email@hidden> wrote:
Hi,
I think this should be simple, but I'm falling at the first hurdle.
I want a script to convert Word's current selection, which is a series of lines of text with cells delimited by tabs, into a table; I'll then apply some formatting. I've tried
tell application "Microsoft Word"
set txt to selection's text object
convert to table txt
end tell
which works, but ignores the tabs (I get a table with only one column). If I try
tell application "Microsoft Word"
set txt to selection's text object
convert to table txt separator separate by tabs
end tell
which I think should work, I get an error: "text object of selection doesn't understand the convert to table message".
Any ideas?
Jeremy
Jeremy Roussak
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
_______________________________________________
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
|