Reputation: 77
In Excel 2008 on Mac, I want to create a hyperlink on sheet 1 on cell "A8" using AppleScript in same Excel document.
<hyperlink ref="A8" location="Sheet1!A20" display="Sheet1!A20" />
I have tried the following script, which does not work:
tell application "Microsoft Excel"
make new workbook
tell worksheet "Sheet1" of active workbook
make new hyperlink of cell "A8" with properties {address :"#Sheet1!A20", text to display:"Sheet1!A20"}
end tell
end tell
Can you help me figure out what to do please?
Upvotes: 0
Views: 1034
Reputation: 46405
This was a tough one! The following works:
tell application "Microsoft Excel"
tell worksheet "Sheet1" of active workbook
make new hyperlink of cell "A8" with properties {address:"", sub address:"$A$20", text to display:"Sheet1!A20"}
end tell
end tell
Note - I have edited this answer to improve it. In the first attempt at this, I did not have the address:""
right. You pointed this out yourself in your comment. This is the missing piece - using ""
as address
creates a reference to "this document". Adding a #
sign (which is what seems to happen when you enter the hyperlink manually) is what caused the problem...
Upvotes: 1