Welcome to MacForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

new word 2008 applescript questions

 
   Macintosh computer (Home) -> Apple Scripts RSS
Next:  Automatic title and saving of the same  
Author Message
G.Miller

External


Since: Jun 13, 2008
Posts: 1



(Msg. 1) Posted: Wed Jul 09, 2008 11:29 am
Post subject: new word 2008 applescript questions
Archived from groups: alt>comp>lang>applescript (more info?)

hi, im stuck trying to create a script that adds data to a word
document. im trying to figure out how to add spaces (ie similar to
typing the return key) between things i insert into a doc as follows:

-open document
-advance the cursor down below the logo that is already there
-type return
-insert the date as text (not as field)
-type return
-add table, format and populate
-advance cursor down below the table
-type return
-insert text from a variable

everything works great except i end up with: the logo, 2 spaces, the
date, the table, 1 space, text
what im looking for is: the logo, 1 space, the date, 1 space, the
table, 1 space, text

if i substitute 'type text selection text "the date"' for the 'insert
date time' step, the spacing is correct, but obviously it just says
"the date". what am i missing? ive read through the word 2004
applescript guide to no avail.

-----script
tell application "Microsoft Word"
open alias ((path to desktop as text) & "letterhead")
set myDoc to active document
-- advance cursor down
navigate text object of selection to goto a line item position
relative count 2
--add space
type paragraph selection
-- insert date, not as field
insert date time at text object of selection date time format "MMMM
dd, yyyy" without insert as field
--add space
type paragraph selection
-- add table, format and populate
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
-- add contact info and contact numbers to table
set content of text object of (get cell from table myAddressTable row
1 column 1) to mycontactaddress
set content of text object of (get cell from table myAddressTable row
1 column 2) to mycontactnumbers
-- align the contact numbers right
set alignment of paragraph format of text object of (get cell from
table myAddressTable row 1 column 2) to align paragraph right
navigate text object of selection to goto a line item position
relative count 2
-- advance cursor down
type paragraph selection
--insert text from variable
set content of text object of selection to myestimatebody
end tell

 >> Stay informed about: new word 2008 applescript questions 
Back to top
Login to vote
Jo_y

External


Since: Jun 22, 2008
Posts: 30



(Msg. 2) Posted: Tue Jul 22, 2008 8:50 am
Post subject: Re: new word 2008 applescript questions [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hey, i use this code to get the date:

set c to (current date) as text
--set X to word 1 of ((current date) as text) & space & word 2...

time is one word (word 5 of date string), so it requies extra
treatment to be able to filter hours, mins and secds.
try it, perhaps helps.

 >> Stay informed about: new word 2008 applescript questions 
Back to top
Login to vote
Jo_y

External


Since: Jun 22, 2008
Posts: 30



(Msg. 3) Posted: Thu Jul 24, 2008 2:18 pm
Post subject: Re: new word 2008 applescript questions [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hey, i use this code to get the date: (perhaps helps)


set c to (current date) as text
set X to word 1 of ((current date) as text) --& space & word 2...
--or
tell (current date) to set {yr, mo, dy, hr, mn, sc} to {year, its
month, day, its hours, its minutes, its seconds}
 >> Stay informed about: new word 2008 applescript questions 
Back to top
Login to vote
Jerry Kindall

External


Since: Jul 09, 2003
Posts: 560



(Msg. 4) Posted: Thu Jul 24, 2008 5:16 pm
Post subject: Re: new word 2008 applescript questions [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article
,
Jo_y wrote:

> tell (current date) to set {yr, mo, dy, hr, mn, sc} to {year, its
> month, day, its hours, its minutes, its seconds}

This is the best way to do it because it works regardless of the date
format. Taking parts of a string can fail if your script is used in
another country. You can also append "as number" or "as text" to the
month so you get the desired numeric or text value, e.g.:

tell (current date) to set {yr, mo, dy, hr, mn, sc} to {its year, its
month as number, day, its hours, its minutes, its seconds}

You can also get the day of the week using "its weekday" -- and this
too can be "as number" or "as text.", e.g.:

tell (current date) to set {yr, mo, dy, hr, mn, sc, wd} to {its year,
its month, day, its hours, its minutes, its seconds, its weekday}

--
Jerry Kindall, Seattle, WA <http://www.jerrykindall.com/>

Send only plain text messages under 32K to the Reply-To address.
This mailbox is filtered aggressively to thwart spam and viruses.
 >> Stay informed about: new word 2008 applescript questions 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Microsoft Excel 2008 and Applescript - Hi, I have a sheet that contains data from column A to column N. Column O makes a sum of datas from column A to column N. When I add datas for some rows, I want my script to copy the sum in previous row to next row. The following script does the jo...

Question about replacing a Macro in Word 2008 with an Appl.. - Hello, Although I've had a Mac for a few years now, I've never delved into Apple script. I find myself needing to start from scratch to replace a Macro in Word 2008 (MS eliminated VBA from this new version of Office - that's another story for another..

New to Applescript - Hello, I'm brand new to Applescript - I've done a lot with VBS but never touched Applescript. Are there some good script repositories online? AppleScript Editors? Manuals? Any help will be greatly appreciated!!! TIA, Bill bill@2burkes.com

Applescript RSS - Is there any way to acquire an RSS feed using Applescript? I'd like to be able to specify the RSS URL, then have Applescript consume the most recent 5 entries. Thanks, A

Use applescript in Keynote - Am trying to use applescript to modify the color of a selected text element on a slide in Keynote. is it possible to have a script that can set the font, size, color of a selected text in keynote using applescript. The dictionary mentions about a..
   Macintosh computer (Home) -> Apple Scripts All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]