LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Insert picture, resize to specific width, keeping height proportio

Hi,

My sub will insert a picture into my template and resize the width to 240.
The original picture aspect ratio will vary, so I will not know the resize
height ahead of time. I have written the below sub all by myself so far, so
there's a good chance there's something wrong with it. It resizes the height
proportionately to the width, then places the bottom left corner of the
picture at the bottom left corner of cell K11.

Dim PicHt As Double
Dim PcWd As Double
Dim PicRatio As Double

PRM.Activate
PRM.Cells(12, 11).Select
PRM.Pictures.Insert "C:\Documents and Settings\Olab\My Documents\0- Wear
Testing\Sketches\" & sStyle & ".jpg"
With PRM.Pictures("Picture 8")
PicHt = .Height
PicWd = .Width
PicRatio = PicHt / PicWd
.Select
.Width = 240
.Height = PicHt * PicRatio
.Top = .Top - .Height + 1
End With

It seems to work so far, but I have two specific questions and if you see
anything else I could do better, please let me know.

1. Is Double the correct data type to use? I know Long doesn't work because
it's integers only. I tried Decimal, but my vba doesn't recognize this data
type. All I need is for it to go to 2 decimal points. I'm not exactly sure
what Double means, even after reading the Help definition. What data type is
best for this?

2. Is there a way to specify the picture to manipulate as the last picture
inserted instead of "Picture 8"? I tried using this method I found in a post:

Dim Pic as Picture
Dim sStyle As String

sStyle = PRM.Cells(5, 2).Text
Set Pic = PRM.Pictures.Insert "C:\Documents and Settings\Olab\My
Documents\0- Wear Testing\Sketches\" & sStyle & ".jpg"
Pic.Selet

But an error states that the quotation mark after "Sketches\" should be the
end of statement. It does work with a normal file path, but I think my
variable is throwing it off.

Thank you!

Thanks!
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert, position, and resize a picture w/ Macro John Excel Discussion (Misc queries) 1 July 10th 07 07:21 PM
Resize Last Row to Fill a Page Width Sloth Excel Discussion (Misc queries) 0 February 17th 06 10:28 PM
resize row height and column height Tom Setting up and Configuration of Excel 3 April 3rd 05 02:03 PM
resize row and colomn height Tom Excel Programming 4 March 11th 05 04:22 PM
get a picture width and height without inserting the picture Dorothy Excel Programming 1 January 13th 05 05:06 AM


All times are GMT +1. The time now is 12:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"