Re: Table in Word 2012
Re: Table in Word 2012
- Subject: Re: Table in Word 2012
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 14 Nov 2012 16:17:18 -0800
- Thread-topic: Table in Word 2012
Title: Re: Table in Word 2012
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