Re: Creating hyperlinks in Word 2004
Re: Creating hyperlinks in Word 2004
- Subject: Re: Creating hyperlinks in Word 2004
- From: Paul Berkowitz <email@hidden>
- Date: Sat, 13 Aug 2005 19:10:21 -0700
- Thread-topic: Creating hyperlinks in Word 2004
Title: Re: Creating hyperlinks in Word 2004
On 8/16/05 3:06 PM, "Matt Deatherage" <email@hidden> wrote:
>
> Can it be done?
>
> tell application "Microsoft Word"
> activate
> set d to content of selection
> set t to text object of selection
> set h to make new hyperlink object at t
> set content of hyperlink address of h to ¬
> "http://dictionary.reference.com/search?q=" & d
> end tell
>
> ...always gives "Microsoft Word got an error: Can't make class hyperlink
> object."
>
> I don't know if I can't make an object at that place, or if I can't make one
> at all. The Word 2004 AppleScript reference is woefully silent on the
> subject, as is Google. Can I do this or not?
In the VBA version there's a special command to make (Add) a hyperlink, requiring both an Anchor (the text range) and Address properties. Probably they would have needed to implement an AppleScript version of this command, or else set things up to allow 'make new hyperlink object'. But they seem to have done neither. You can still do it the old way, via 'do Visual Basic':
tell application "Microsoft Word"
activate
set d to content of selection
do Visual Basic "ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, _
Address:=\"http://dictionary.reference.com/search?q=" & d & "\""
end tell
I'll report the bug.
--
Paul Berkowitz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden