|
Related Topics:
| Help with script, please - Here is the script: tell set foo to the selection set foo to item 1 of foo set address_ to address of item 1 of to recipient of foo if not (name of item 1 of to recipient of foo exists) then set text..
Why this script doesn't work ? - The script: tell activate repeat set w to display dialog default answer set wSal to text returned of w display dialog wSal
Help with System Preferences script - From an obvious novice: I'd like to have a script for my wife that will 1.open the display and 2.select a certain screen and colors ( i.e. I can get as far as opening the pane but I can't..
"Insert" script for BBEdit 7.1 - Hello, I want to write a script for BBEdit 7.1 using the command from the menu. The purpose is to insert selected files in one open file. But when recording from the menu doesn't give any result. Looking at the I..
Excel Script help needed - Hello, Let me preface this with the statement that I am not that familiar with Macs, I have 20 years with PC's Servers, Unix etc, but not Mac. I do have a somewhat urgent need and hope somebody can help me, I can even pay if that is what it..
|
|
|
Next: Apple Scripts: - Item Numbers-SUPER MISC (0/1) Need Help on Scripting Pro..
|
| Author |
Message |
External

Since: Jun 13, 2008 Posts: 12
|
(Msg. 1) Posted: Thu Jul 03, 2008 6:50 am
Post subject: word 2008 script questions Archived from groups: alt>comp>lang>applescript (more info?)
|
|
|
hi, just about as amateur as it can get when it comes to applescript.
i was able to create a script that i used to call from a filemaker 7
database that took information from a record in the database, opened
word (version X), and basically inserted the information. all was
well until i upgraded to leopard, necessitating and upgrade to
filemaker 9 and word 2008. my old script used VBA and now im trying
to redo it using applescript.
ive been searching online, trying to piece things together but have
run into a snag that i cannot figure out.
so far i have....
tell application "FileMaker Pro"
tell layout "Create Estimate"
set mycontactaddress to cellValue of field "contact_address" of
current record
end tell
end tell
tell application "Finder"
open file "letterhead" of desktop
end tell
tell application "Microsoft Word"
activate
set myDoc to active document
set myAddressTable to make new table at myDoc with properties
{number of rows:1, number of columns:2}
set enable borders of border options of myAddressTable to false
set content of text object of (get cell from table myAddressTable
of myDoc row 1 column 1) to "Cell 1, 1"
end tell
There are two problems.
1. if i run the script with Word initially closed, i get the error
"Microsoft Word got an error: Cant get active document." on the 'set
myDoc to active document' step.
if Word is active but there are no documents open, i get and error
"Microsoft Word got an error: Cant make class table." on the 'set
myAddressTable to make new table...' step.
if Word is active and "letterhead" is open, then it doesn't produce an
error on either of those steps.
is the script getting ahead of itself (thats what it seems like). can
i get it to pause between steps?
2. i get the error "Microsoft Word got an error: myAddressTable of
active document doesnt understand the get cell from table message."
on the 'set content of text object...' step.
ive tried deleting that line and replacing it with "set myAddressCell
to cell 1 of row 1 of myAddressTable of myDoc" only to get the error
"Microsoft Word got an error: The object you are trying to access does
not exist" with 'cell 1' being the highlighted object that the error
refers to.
all i am trying to do at this point is insert text into the first cell
in the table i created.
any help is appreciated. thanks. |
|
| Back to top |
|
 |  |
External

Since: Jun 13, 2008 Posts: 12
|
(Msg. 2) Posted: Thu Jul 03, 2008 8:04 am
Post subject: Re: word 2008 script questions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Jul 3, 10:21 am, Jolly Roger <jollyro....DeleteThis@pobox.com> wrote:
> In article
> <c5d1a6b4-d5f8-4951-a3b2-a8af83429....DeleteThis@r66g2000hsg.googlegroups.com>,
>
> "G.Miller" <geoff.w.mil....DeleteThis@gmail.com> wrote:
> > tell application "Finder"
> > open file "letterhead" of desktop
> > end tell
> > tell application "Microsoft Word"
> > activate
> > set myDoc to active document
>
> Rather than doing this, I would suggest telling Microsoft Word to open
> the document directly.
>
> --
> Please send all responses to the relevant news group rather than directly
> to me, as E-mail sent to this address may be devoured by my very hungry
> SPAM filter. Due to Google's refusal to prevent spammers from posting
> messages through their servers, I often ignore posts from Google Groups.
> You'll need to use a real news reader if you want me to see your posts.
>
> JR
the file 'letterhead' of desktop is an alias to a locked word doc that
exists elsewhere. because this script will be used by different
users, i dont know how to reference it. even if i move the original
file to the desktop on each computer, the username is different and so
the name of the path is different.
tell application "Microsoft Word"
open alias ":Users:user1:desktop:testhead.doc"
will not work for 'user2' or 'user3' |
|
| Back to top |
|
 |  |
External

Since: Aug 30, 2005 Posts: 804
|
(Msg. 3) Posted: Thu Jul 03, 2008 8:43 am
Post subject: Re: word 2008 script questions [Login to view extended thread Info.] Imported from groups: per prev. post (more info?)
|
|
|
This message is not archived |
|
| Back to top |
|
 |  |
External

Since: Nov 05, 2007 Posts: 466
|
(Msg. 4) Posted: Thu Jul 03, 2008 9:21 am
Post subject: Re: word 2008 script questions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article
<c5d1a6b4-d5f8-4951-a3b2-a8af83429765 DeleteThis @r66g2000hsg.googlegroups.com>,
"G.Miller" <geoff.w.miller DeleteThis @gmail.com> wrote:
> tell application "Finder"
> open file "letterhead" of desktop
> end tell
> tell application "Microsoft Word"
> activate
> set myDoc to active document
Rather than doing this, I would suggest telling Microsoft Word to open
the document directly.
--
Please send all responses to the relevant news group rather than directly
to me, as E-mail sent to this address may be devoured by my very hungry
SPAM filter. Due to Google's refusal to prevent spammers from posting
messages through their servers, I often ignore posts from Google Groups.
You'll need to use a real news reader if you want me to see your posts.
JR |
|
| Back to top |
|
 |  |
External

Since: Jun 13, 2008 Posts: 12
|
(Msg. 5) Posted: Thu Jul 03, 2008 12:09 pm
Post subject: Re: word 2008 script questions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Jul 3, 2:02 pm, Jolly Roger <jollyro....RemoveThis@pobox.com> wrote:
> In article <michelle-9174DD.08432403072....RemoveThis@news.east.cox.net>,
> Michelle Steiner <miche....RemoveThis@michelle.org> wrote:
>
> > In article
> > <198e6c80-5c05-4121-b1ae-9e83797af....RemoveThis@z72g2000hsb.googlegroups.com>,
> > "G.Miller" <geoff.w.mil....RemoveThis@gmail.com> wrote:
>
> > > tell application "Microsoft Word"
> > > open alias ":Users:user1:desktop:testhead.doc"
> > > will not work for 'user2' or 'user3'
>
> > But this should:
>
> > tell application "Microsoft Word"
> > open alias ((path to desktop as text) & "testhead.doc")
>
> Yep - "path to" is an appropriate way to reference things in relative or
> unknown full paths.
>
> You can read all about the "path to" command in the Standard Additions
> dictionary (File > Open Dictionary in Script Editor).
>
> --
> Please send all responses to the relevant news group rather than directly
> to me, as E-mail sent to this address may be devoured by my very hungry
> SPAM filter. Due to Google's refusal to prevent spammers from posting
> messages through their servers, I often ignore posts from Google Groups.
> You'll need to use a real news reader if you want me to see your posts.
>
> JR
thanks, that works great, but im still getting the 2nd error...
2. i get the error "Microsoft Word got an error: myAddressTable of
active document doesnt understand the get cell from table message."
on the 'set content of text object...' step.
ive tried deleting that line and replacing it with "set myAddressCell
to cell 1 of row 1 of myAddressTable of myDoc" only to get the error
"Microsoft Word got an error: The object you are trying to access does
not exist" with 'cell 1' being the highlighted object that the error
refers to. |
|
| Back to top |
|
 |  |
External

Since: Nov 05, 2007 Posts: 466
|
(Msg. 6) Posted: Thu Jul 03, 2008 1:02 pm
Post subject: Re: word 2008 script questions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <michelle-9174DD.08432403072008.DeleteThis@news.east.cox.net>,
Michelle Steiner <michelle.DeleteThis@michelle.org> wrote:
> In article
> <198e6c80-5c05-4121-b1ae-9e83797afbd4.DeleteThis@z72g2000hsb.googlegroups.com>,
> "G.Miller" <geoff.w.miller.DeleteThis@gmail.com> wrote:
>
> > tell application "Microsoft Word"
> > open alias ":Users:user1:desktop:testhead.doc"
> > will not work for 'user2' or 'user3'
>
> But this should:
>
> tell application "Microsoft Word"
> open alias ((path to desktop as text) & "testhead.doc")
Yep - "path to" is an appropriate way to reference things in relative or
unknown full paths.
You can read all about the "path to" command in the Standard Additions
dictionary (File > Open Dictionary in Script Editor).
--
Please send all responses to the relevant news group rather than directly
to me, as E-mail sent to this address may be devoured by my very hungry
SPAM filter. Due to Google's refusal to prevent spammers from posting
messages through their servers, I often ignore posts from Google Groups.
You'll need to use a real news reader if you want me to see your posts.
JR |
|
| Back to top |
|
 |  |
External

Since: Aug 30, 2005 Posts: 804
|
(Msg. 7) Posted: Thu Jul 03, 2008 2:03 pm
Post subject: Re: word 2008 script questions [Login to view extended thread Info.] Imported from groups: per prev. post (more info?)
|
|
|
This message is not archived |
|
| Back to top |
|
 |  |
External

Since: Nov 05, 2007 Posts: 466
|
(Msg. 8) Posted: Thu Jul 03, 2008 2:57 pm
Post subject: Re: word 2008 script questions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article
<93c4506e-ceb0-4445-a4d8-b4ce2fd482c5.DeleteThis@j22g2000hsf.googlegroups.com>,
"G.Miller" <geoff.w.miller.DeleteThis@gmail.com> wrote:
> im still getting the 2nd error...
>
> 2. i get the error "Microsoft Word got an error: myAddressTable of
> active document doesnıt understand the get cell from table message."
> on the 'set content of text object...' step.
> ive tried deleting that line and replacing it with "set myAddressCell
> to cell 1 of row 1 of myAddressTable of myDoc" only to get the error
> "Microsoft Word got an error: The object you are trying to access does
> not exist" with 'cell 1' being the highlighted object that the error
> refers to.
Try this on for size:
(Note: Usenet or your news reader may line wrap long lines in the script
below. You'll have to fix such line wraps manually, by deleting the
appropriate carriage returns, before the script will compile correctly
on your computer.)
-- begin script
tell application "Microsoft Word"
activate
set myDoc to make new document
set myAddressTable to make new table at myDoc with properties
{number of rows:1, number of columns:2}
set enable borders of myAddressTable's border options to false
repeat with col from 1 to 2
my SetCellContents(myAddressTable, 1, col, "row 1, column " &
col)
end repeat
end tell
on SetCellContents(myTable, myRow, myColumn, myContents)
tell application "Microsoft Word"
set myCell to get cell from table myTable row myRow column
myColumn
set myText to the text object of myCell
set myText's content to myContents
end tell
end SetCellContents
-- end script
--
Please send all responses to the relevant news group rather than directly
to me, as E-mail sent to this address may be devoured by my very hungry
SPAM filter. Due to Google's refusal to prevent spammers from posting
messages through their servers, I often ignore posts from Google Groups.
You'll need to use a real news reader if you want me to see your posts.
JR |
|
| Back to top |
|
 |  |
External

Since: Jun 13, 2008 Posts: 12
|
(Msg. 9) Posted: Thu Jul 03, 2008 3:33 pm
Post subject: Re: word 2008 script questions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Jul 3, 3:57 pm, Jolly Roger <jollyro... DeleteThis @pobox.com> wrote:
> In article
> <93c4506e-ceb0-4445-a4d8-b4ce2fd48... DeleteThis @j22g2000hsf.googlegroups.com>,
>
> "G.Miller" <geoff.w.mil... DeleteThis @gmail.com> wrote:
> > im still getting the 2nd error...
>
> > 2. i get the error "Microsoft Word got an error: myAddressTable of
> > active document doesnıt understand the get cell from table message."
> > on the 'set content of text object...' step.
> > ive tried deleting that line and replacing it with "set myAddressCell
> > to cell 1 of row 1 of myAddressTable of myDoc" only to get the error
> > "Microsoft Word got an error: The object you are trying to access does
> > not exist" with 'cell 1' being the highlighted object that the error
> > refers to.
>
> Try this on for size:
>
> (Note: Usenet or your news reader may line wrap long lines in the script
> below. You'll have to fix such line wraps manually, by deleting the
> appropriate carriage returns, before the script will compile correctly
> on your computer.)
>
> -- begin script
> tell application "Microsoft Word"
> activate
> set myDoc to make new document
> set myAddressTable to make new table at myDoc with properties
> {number of rows:1, number of columns:2}
> set enable borders of myAddressTable's border options to false
>
> repeat with col from 1 to 2
> my SetCellContents(myAddressTable, 1, col, "row 1, column " &
> col)
> end repeat
> end tell
>
> on SetCellContents(myTable, myRow, myColumn, myContents)
> tell application "Microsoft Word"
> set myCell to get cell from table myTable row myRow column
> myColumn
> set myText to the text object of myCell
> set myText's content to myContents
> end tell
> end SetCellContents
> -- end script
>
> --
> Please send all responses to the relevant news group rather than directly
> to me, as E-mail sent to this address may be devoured by my very hungry
> SPAM filter. Due to Google's refusal to prevent spammers from posting
> messages through their servers, I often ignore posts from Google Groups.
> You'll need to use a real news reader if you want me to see your posts.
>
> JR
thank you so much.
i think the problem was i was asking for row 1 column 1 of myDoc, when
i didnt need to reference myDoc at all...
this is what it should be. i was able to back into it using your
subroutine.
set content of text object of (get cell from table myAddressTable row
1 column 1) to "the text i was trying to put into the cell" |
|
| Back to top |
|
 |  |
External

Since: Nov 05, 2007 Posts: 466
|
(Msg. 10) Posted: Thu Jul 03, 2008 5:48 pm
Post subject: Re: word 2008 script questions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article
<5e56cb44-7850-4633-a9ad-3cb480a70022.TakeThisOut@s50g2000hsb.googlegroups.com>,
"G.Miller" <geoff.w.miller.TakeThisOut@gmail.com> wrote:
> On Jul 3, 3:57 pm, Jolly Roger <jollyro....TakeThisOut@pobox.com> wrote:
> > In article
> > <93c4506e-ceb0-4445-a4d8-b4ce2fd48....TakeThisOut@j22g2000hsf.googlegroups.com>,
> >
> > on SetCellContents(myTable, myRow, myColumn, myContents)
> > tell application "Microsoft Word"
> > set myCell to get cell from table myTable row myRow column myColumn
> > set myText to the text object of myCell
> > set myText's content to myContents
> > end tell
> > end SetCellContents
>
> thank you so much.
>
> i think the problem was i was asking for row 1 column 1 of myDoc, when
> i didnt need to reference myDoc at all...
>
> this is what it should be. i was able to back into it using your
> subroutine.
>
> set content of text object of (get cell from table myAddressTable row
> 1 column 1) to "the text i was trying to put into the cell"
I recommend using subroutines (called "handlers" in AppleScript
terminology) whenever possible. Doing so will help make your code
easier to update and more scalable over time.
--
Please send all responses to the relevant news group rather than directly
to me, as E-mail sent to this address may be devoured by my very hungry
SPAM filter. Due to Google's refusal to prevent spammers from posting
messages through their servers, I often ignore posts from Google Groups.
You'll need to use a real news reader if you want me to see your posts.
JR |
|
| Back to top |
|
 |  |
|