ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Picture Import Questions - Size and Placement (https://www.excelbanter.com/excel-programming/338909-picture-import-questions-size-placement.html)

Shatin[_2_]

Picture Import Questions - Size and Placement
 
I use following lines to import two pictures into a worksheet:

With ActiveSheet.Pictures
.Insert ("http://www.abc.com/picture1.jpg")
.Insert ("http://www.abc.com/picture2.jpg")
End With

Both pictures are too big; also the placement of the pictures is rather
haphazard.

Would appreciate it if someone could me how to:

- place picture1 somewhere near to cell A1 and picture2 near to cell A20.
- resize height of picture1 to 3 inches
- resize width of picture2 to 4 inches

TIA.



Dave Peterson

Picture Import Questions - Size and Placement
 
This kind of thing works ok when I import a picture from my harddrive--I've
never used it for web sites:

Option Explicit
Sub testme02()

Dim myPicNames As Variant
Dim myPict As Picture
Dim myAddresses As Variant
Dim myRng As Range
Dim iCtr As Long

myPicNames = Array("c:\pict1.jpg", _
"C:\pict2.jpg")

myAddresses = Array("a1:c3", "e1:g3")

If UBound(myPicNames) < UBound(myAddresses) Then
MsgBox "design error"
Exit Sub
End If

With Worksheets("sheet1")
For iCtr = LBound(myPicNames) To UBound(myPicNames)
Set myRng = .Range(myAddresses(iCtr))
Set myPict = .Pictures.Insert(myPicNames(iCtr))
myPict.Top = myRng.Top
myPict.Width = myRng.Width
myPict.Height = myRng.Height
myPict.Left = myRng.Left
myPict.Placement = xlMoveAndSize
Next iCtr
End With
End Sub


Shatin wrote:

I use following lines to import two pictures into a worksheet:

With ActiveSheet.Pictures
.Insert ("http://www.abc.com/picture1.jpg")
.Insert ("http://www.abc.com/picture2.jpg")
End With

Both pictures are too big; also the placement of the pictures is rather
haphazard.

Would appreciate it if someone could me how to:

- place picture1 somewhere near to cell A1 and picture2 near to cell A20.
- resize height of picture1 to 3 inches
- resize width of picture2 to 4 inches

TIA.


--

Dave Peterson


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com