Results 1 to 4 of 4

Insert picture problem

Threaded View

  1. #1
    Registered User
    Join Date
    06-26-2011
    Location
    Kuopio
    MS-Off Ver
    Excel 2007
    Posts
    18

    Insert picture problem

    Hello,

    I have a problem, I'm trying to use this code to add picture/image in wanted cell, in this case at range A51:D66, code works fine but everytime I select picture, it's placed at range A3:D18.


    Sub InsertPicture2()
    Dim myPicture As Variant
    myPicture = Application.GetOpenFilename _
    ("Pictures (*.gif; *.jpg; *.bmp; *.tif),*.gif; *.jpg; *.bmp; *.tif", , "Select Picture to Import")
    If myPicture = False Then Exit Sub
    Application.ScreenUpdating = False
    Dim iLeft#, iTop#, iWidth#, iHeight#
    With Range("A51")
    iLeft = .Left
    iTop = .Top
    .Select
    End With
    Set myPicture = ActiveSheet.Pictures.Insert(myPicture)
    With Range("A51:D66")
    iWidth = .Width: iHeight = .Height
    End With
    With myPicture
    .Width = iWidth: .Height = iHeight
    End With
    Application.ScreenUpdating = True
    End Sub
    I have a commandbutton that hides/unhides rows 28:66, and row 49 contains button "add picture". Point is that when I unhide rows, "add picture"-button appears, I push it and get to select picture. It does appear but at A3:D18.

    I tried it on a blank sheet, picture was placed B5:G20 :p

    No matter how large/small image is, code resizes it but at the wrong range :P
    Last edited by Zahhhaaaa; 07-25-2011 at 07:12 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1