Tuesday, October 23, 2018

#1 2018-08-09 12:32:10 pm

Donatelo
Member
Registered: 2018-04-06
Posts: 4

Setting Properties for a Shape in Excel

Hi I a new to scripting with applescript and was hoping someone could help me with setting the properties for a shape that I created?
I am trying to fill the shape with a picture and to make the shape a hyperlink to a web page.
I've tried to find an example of this, but so far I have not had a lot of luck.
When I try to fill the shape with a picture I get the error;
"Microsoft Excel got an error: The object you are trying to access does not exist"
If some one could show me an example of the proper format I would be very grateful.
Bellow is an example of the Script I am using to try to fill a shape with a picture.
Thank you


Applescript:

tell application "Microsoft Excel"
   make new shape at the beginning of worksheet 1 of workbook "Workbook1.xls" with properties {fill format picture "Macintosh HD:Users:mac39:Pictures:6.jpg"}
end tell

Model: iMac
Browser: Firefox 61.0
Operating System: Mac OS X (10.13 Public Beta)

Offline

 

#2 2018-08-09 01:29:49 pm

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 315

Re: Setting Properties for a Shape in Excel

This is working for me:

Applescript:


tell application "Microsoft Excel"
   set currentWorkbook to workbook 1
   tell currentWorkbook
       tell worksheet 1
           set pictureShape to make new shape at the beginning
           user picture pictureShape picture file "[put HFS path here]"
       end tell
   end tell
end tell

Last edited by t.spoon (2018-08-09 01:30:02 pm)


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

#3 2018-08-09 01:42:27 pm

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 315

Re: Setting Properties for a Shape in Excel

Forgot the hyperlink part of the question.

I'm having trouble with that. I tried setting a hyperlink for the picture shape manually through the GUI and confirmed it worked. But then when I use Applescript to retrieve the hyperlink property of the shape, the value is still "missing value."

It won't let me set the hyperlink value for the shape. In the Excel AS Dictionary, it says the access to the hyperlink property is "get,"  not "get/set," implying it can't be modified via script.

But since that field isn't even populating to Applescript for a working hyperlink, I'm not sure what's going on... I may mess around with it more if I have time.

Warning, I'm on Excel 2008, some things may be different for my version.


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

#4 2018-08-09 02:07:38 pm

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 315

Re: Setting Properties for a Shape in Excel

I don't know why it wasn't returning the hyperlink information to my script at first. I tried again and it did start returning the hyperlink data for shapes once I had manually created a hyperlink for a shape.

But is still doesn't appear to be writable via Applescript.

You could GUI script it.


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

#5 2018-08-09 02:55:53 pm

Donatelo
Member
Registered: 2018-04-06
Posts: 4

Re: Setting Properties for a Shape in Excel

Thanks Very much this was a great help! I will try scripting via the GUI and let you know
Thanks Again!

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)