Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Excel 2007 AddPicture help needed

I have an application that generates reports displayed in Excel using
VBA code. Our company just upgraded to Office 2007 and MS has changed
the behavior of the AddPicture method so I am trying to convert my
2003 reports over. It used to be that I could just add a picture to a
worksheet and manipulate it after the fact. Now the Shapes.AddPicture
method requires a height and width value; unfortunately, I don't know
the height or width of my picture going in as the pictures are
supplied by the user and can vary in size and h/w ratio. I've been
banging on this trying to figure out how to add the pictures without
specifying a size or barring that, "ask" the picture how big it is but
can't figure that one out either. If someone could point out the
right way to do this I'd appreciate it.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Excel 2007 AddPicture help needed

I don't have XL2007, but this is how I do it in XL2003:

With rDestCell
'Create the new picture
'(arbitrarily sized as a square that is the height of the rDestCells)
Set oNewPic = shtWS.Shapes.AddPicture( _
Filename:=strFileLoc, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=.Left + 1, Top:=.Top + 1, Width:=.Height - 1, Height:=.Height - 1)

'Maintain original aspect ratio and set to full size
oNewPic.LockAspectRatio = msoTrue
oNewPic.ScaleHeight Factor:=1, RelativeToOriginalSize:=msoTrue
oNewPic.ScaleWidth Factor:=1, RelativeToOriginalSize:=msoTrue
End with

Is that something you can work with?
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)


wrote in message
...
I have an application that generates reports displayed in Excel using
VBA code. Our company just upgraded to Office 2007 and MS has changed
the behavior of the AddPicture method so I am trying to convert my
2003 reports over. It used to be that I could just add a picture to a
worksheet and manipulate it after the fact. Now the Shapes.AddPicture
method requires a height and width value; unfortunately, I don't know
the height or width of my picture going in as the pictures are
supplied by the user and can vary in size and h/w ratio. I've been
banging on this trying to figure out how to add the pictures without
specifying a size or barring that, "ask" the picture how big it is but
can't figure that one out either. If someone could point out the
right way to do this I'd appreciate it.






Reply
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
Help needed with a formula for dates in excel 2007 dloc Excel Worksheet Functions 2 March 17th 10 03:04 PM
If then else needed in Excel 2007 Legal Learning Excel Worksheet Functions 3 November 5th 09 01:32 AM
Excel 2007 Prohibits Shapes.AddPicture from URL? Lazzaroni Excel Programming 4 June 8th 07 09:53 PM
Excel 2007 - WordArt Help Needed [email protected] Excel Programming 1 January 30th 07 12:09 AM
Shapes.AddPicture run-time error Matt[_12_] Excel Programming 0 August 22nd 03 04:05 PM


All times are GMT +1. The time now is 05:24 PM.

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

About Us

"It's about Microsoft Excel"