Re: scale
Re: scale
- Subject: Re: scale
- From: Andrew Oliver <email@hidden>
- Date: Mon, 20 Feb 2017 13:04:49 -0800
Thank you for reminding me how much I loathe Excel scripting :)
This is what I came up with. Hopefully it gets you closer:
set imageWidth to 150 tell application id "com.microsoft.Excel" activate set newPic to make new picture at beginning of active sheet of active workbook with properties {file name:"theImage", left position:15.0, top:15.0, placement:placement move} set newPic's lock aspect ratio to true scale width newPic factor 1.0 scale scale from top left with relative to original size set w to width of newPic set f to imageWidth / w scale width newPic factor f scale scale from top left without relative to original size end tell
The idea here is to import the image, then immediately scale it to full-size. This allows you to extract the true image width, from which you can determine the scaling factor needed. Then I scale the width by the appropriate factor. Since aspect ratio is locked, the height changes accordingly.
Andrew :)
On Feb 20, 2017, at 11:04 AM, Julien Battist < email@hidden> wrote:
Hi Andrew,
Let me reformulate my question....
I am placing a picture in excel ....
set imageWidth to 150
set imageHeight to 150 --- this should not be 150 but the same % scale factor of imageWidth which I don't know how to handle
tell application id "com.microsoft.Excel"
activate
set newPic to make new picture at beginning of active sheet of active workbook with properties {file name:"PathTofile", left position:15.0, top:15.0, height:imageHeight, width:imageWidth, placement:placement move}
end tell
So 150 is the fixed width size for every picture I want to place. The image height needs to be corrected to a proportional size. So if 150 width = to scale factor 33% of the picture then I need to adapt the scale factor for the height also to 33%.
Much appriciate for any feedback, Julien
There is no ‘scale’ property of a picture's ‘height’. Excel’s dictionary states that ‘height’ is a real, and therefore has no further properties.
Why not just do something like:
tell application id "com.microsoft.Excel"
tell active sheet of active workbook
tell picture 1
set lock aspect ratio to false
set h to get height
set height to h * 1.5
end tell
end tell
end tell
(you need to unlock the aspect ratio in order to scale width and height independently)
Andrew
:)
On Feb 20, 2017, at 3:34 AM, Julien Battist < email@hidden> wrote:
Hi all,
It seems to be impossible to get the scale factor of a place picture in Excel 2011.
I am able to place an image but I need to make it proportional. So width size is fixed, height size need to be proportional adapted.
Any help is much appreciated.
tell application id "com.microsoft.Excel"
tell active sheet of active workbook
tell picture 1
get height
--- 150.0
get scale of height
--- missing value
end tell
end tell
end tell
Many thanks,Julien
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list ( email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
- Follow-Ups:
- Re: scale
- From: Julien Battist <email@hidden>
References: | |
| >scale (From: Julien Battist <email@hidden>) |
| >Re: scale (From: Andrew Oliver <email@hidden>) |
| >Re: scale (From: Julien Battist <email@hidden>) |