Link to home
Start Free TrialLog in
Avatar of tlengnick
tlengnickFlag for United States of America

asked on

Use vb6 program to change size of image in an excel worksheet

I'm using the following code to insert an image into an Excel 2007 Worksheet utilizing VB6 (not a macro).

Const msoFalse = 1
Sub positionpicture()
Dim p As Picture
Dim wkb As Workbook
Dim wks As Worksheet
Dim pBeginX As Single 'relative to upper-left corner of document
Dim pBeginY As Single 'relative to upper-left corner of document
Dim pEndX As Single 'relative to upper-left corner of document
Dim pEndY As Single 'relative to upper-left corner of document
Dim InchToPoint As Single

    Set wkb = ActiveWorkbook
    Set wks = Sheets("Sheet1")
   
    '18 points per .25 inches
    InchToPoint = 18 / 0.25
   
    '2 inches from the left, 6 inches down
    pBeginX = 1 * InchToPoint
    pBeginY = 1 * InchToPoint
    pEndX = 11 * InchToPoint
    pEndY = 11 * InchToPoint
   
    Set p = wks.Pictures.Insert(App.Path & "\" & "tlsig.jpg")

    'keep or lock the aspect ratio
    p.ShapeRange.LockAspectRatio = msoFalse
    'Top left corner
    p.Locked = False
    p.Left = pBeginX
    p.Top = pBeginY
End Sub

How can I resize the image and position it? The image is not responding to the above attempt to position it nor is it responding to the following code:
p.left = wks.range("A39").left
p.top = wks.range("A39").top

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of tlengnick
tlengnick
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tlengnick

ASKER

Found the answer online... figured I'd add it to knowledgebase.