Re: How to skip Project Gallery in Word w/ Applescript

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Thank you for trying to help, Geoff.

At first I thought "System Events" could be the right clue - though your
lines didn't really work. Word's Project Gallery is a real nightmare. I
could not come to a reliable solution, for the backward compatibility I
need. After hours of experimentation I had a working script on one test
machine with OS 10.48 , only to find that it didn't work at all on an older
one with OS 10.15, where the System Events dictionary didn't even know
"keystroke".

Maybe I give up on using applescript for the task at hand and use written
documentation to ask the user to close the Project Gallery by hand before
continuing. (It's a first-use-situation with a Word add-in, where I can not
rely on the existence of a certain template in the right folder.)

That's technical progress, I guess.

Thanks again,
Hans


<ruthlesslightning@xxxxxxxxx> schrieb im Newsbeitrag
news:1165444064.087301.23920@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hans:

Don't know if this would achieve the desired result. I'm a bit of a
hack with AppleScript, but here's what I came up with:
tell application "Microsoft Word"
activate
delay 2
tell application "System Events"
keystroke tab using shift down
--keystroke arrow down
keystroke (key code 125)
keystroke tab
keystroke return
end tell
end tell

What that does is shift+tab over to the list of templates (defaults to
"Blank Documents." Then, it arrows down to "My Templates." Then, it
hits RETURN, to select the FIRST template in the list. If yours is the
second template that's going to show up under "My Templates," just add
the line:
keystroke(key code 125) between "keystroke tab" and "keystroke return."
That should do it.

HTH.
Cheers,
Geoff Lilley
Microsoft Office Master Instructor (2000/XP)
Apple Certified HelpDesk Specialist (OS X 10.4)

Hans Zybura wrote:
Hi,
I want to hand our customers using MacOS 10.1 (or later) and MacOffice (X
or
2004) a simple applescript, which is meant to do the following:
- start Word
- open a new document with our special template attached
- do some more VBA code

Basically it looks like:

tell application "Microsoft Word"
launch
do Visual Basic "
Documents.Add Template:=/"ourTemplate.dot/", NewTemplate:=False
"
end tell

In fact there will be a lot more lines of VBA code following the initial
one, but there's a catch even in these few lines: When the user has set
Word
to start with the Project Gallery, the applescript will throw an error
when
reaching the line containing "do Visual Basic...". I've done a lot of
experimentation and an extensive search on this, but found some advice
concerning a similar problem with Excel only. That did not change the
problem with Word.

Is there a way to make an applescript stop the Project Gallery from
showing
up or - next best thing - to close it immediately? Without changing the
users settings to "Do not start Word with automatically showing up the
damned Project Gallery" beforehand?

Thanks in advance
Hans



.



Relevant Pages

  • Re: Updating all fields (including header and footer) in a document using AppleScript
    ... The AppleScript process of creating a new document based off of an existing ... template ­ as one does via the Project Gallery ­ is vastly improved in Mac ... the Project Gallery does require the steps / sample code that Diaya pointed ... Attach your template to the new document. ...
    (microsoft.public.mac.office.word)
  • AppleScript to create a document based on a custom template???
    ... I have a custom template which is working. ... Project Gallery does. ... But is there really no way to do this more directly with AppleScript? ... turned off display of the Project Gallery at startup (or the user has turned ...
    (microsoft.public.mac.office.word)
  • Any AppleScripters?
    ... I want to assign a hotkey so I can, via AppleScript, open a new document from an existing template (like the File> Project Gallery> ...
    (microsoft.public.mac.office.word)
  • Re: Word vX templates ?
    ... In the Project Gallery there is an entry called "Word Document". ... That global template may or may not exist as a file. ... Immediately Quit Word to force it to save the new location back to disk. ... that user's file locations preferences. ...
    (microsoft.public.mac.office.word)
  • Re: Duplicate template icons in Project Gallery
    ... Project Gallery should clean itself up if you simply reboot the computer. ... noticed that there are two entries in the Project Gallery for each template ... That is, in resolving the extra pointer to the template, Word ...
    (microsoft.public.mac.office.word)