Can Automator Do This
November 26, 2008 2:26 PM   Subscribe

I want Leopard's Automator to do something seemingly simple, but can't get it to work. Can anyone help?

When I used Office 2004 I had a simple VBA script that typed the current date, hit [return], hit [tab], then typed the current time. I used this script every time I started notes for a meeting, or other types of entries.

Can Automator do this? Again, the steps:

Add Current Date
Return Character
Tab Character
Add Current Time
Add a ":" character

Pretty simple, but I can't get it to work.
posted by crapples to Computers & Internet (8 answers total)
 
Is there a reason why you can't just use a Word macro to do this?
posted by Acheman at 3:11 PM on November 26, 2008


Response by poster: The 08 Version of Office doesn't support Macros, right?
posted by crapples at 4:06 PM on November 26, 2008


acheman, newer versions of Word on the Mac can't run VBA macros.

I don't think Automator can do this -- but AppleScript can. Fire up Script Editor in Applications -> Applescript and try the following:

set {year:y, month:m, day:d, time string:t} to (current date)
set month to (m) as string
set day to (d) as string
set time_format to (t) as string

tell application "System Events"
keystroke date_format
key down return
key code 48
keystroke time_format
keystroke ":"
end tell

I'm sure you can figure out how to tweak things from there. You can then save that out into a script or an application to attach to a trigger somewhere.
posted by eschatfische at 4:09 PM on November 26, 2008


Jeez, I pasted a test version of the script. Here's the one I meant to paste:

set {year:y, month:m, day:d, time string:t} to (current date)

set month_ to (m) as string
set day_ to (d) as string
set year_ to (y) as string
set time_ to (t) as string

tell application "System Events"
keystroke month_ & " " & day_ & ", " & year_
key down return
key code 48
keystroke time_
keystroke ":"
end tell

posted by eschatfische at 4:13 PM on November 26, 2008


Best answer: Some days I wish you could just edit posts. The script above will work fine in script editor, but not so much in Word proper.

set {year:y, month:m, day:d, time string:t} to (current date)

set month_ to (m) as string
set day_ to (d) as string
set year_ to (y) as string
set time_ to (t) as string

tell application "Microsoft Word"
insert text month_ & " " & day_ & ", " & year_ & return & tab & time_ & ":" at end of text object of active document
end tell
posted by eschatfische at 4:31 PM on November 26, 2008


Response by poster: Thanks so much for your help. But I have to just express my frustration that something this simple can no longer be done without programming skills. You used to be able to just "record" an action like this in VBA and, Viola, it was done.

But - I really do appreciate the help. I'll test it out right now.
posted by crapples at 5:39 PM on November 26, 2008


I doubt you're looking for payware, but I can't help mentioning TextExpander here. If I type "ddate" I get "27 November 2008" (for inserting the date), and if I type "Ddate" I get "2008_11_27_" (for naming files).

I'm fairly certain you can also do times, and you can do a whole host of other abbreviated typing. And it's quicker than running an Apple Script.

And I'm with you, I've found Automator infinitely frustrating.
posted by jpcody at 9:26 PM on November 26, 2008


Seconding TextExpander - I use it for this exact purpose, plus a ton of other macro and autocompletion type stuff, correcting words I regularly spell wrongly, churning out 'phone numbers and addresses, making templates for HTML documents, &c. &c.

It might seem like overkill spending $30 to fix this one problem, but it's really a cracking piece of software.
posted by jack_mo at 3:02 PM on November 27, 2008


« Older Airline Christmas Gift   |   Looking for writing software which can parse my... Newer »
This thread is closed to new comments.