Results 1 to 3 of 3

Intermittent Runtime Error when inserting picture

Threaded View

vamosj Intermittent Runtime Error... 04-19-2009, 10:47 AM
mrice Re: Intermittent Runtime... 04-19-2009, 01:51 PM
vamosj Re: Intermittent Runtime... 04-20-2009, 04:36 AM
  1. #1
    Forum Contributor vamosj's Avatar
    Join Date
    04-23-2004
    Location
    Oregon
    MS-Off Ver
    2010
    Posts
    294

    Intermittent Runtime Error when inserting picture

    I'm having difficulty nailing this one down as it does it on occasion and I can't figure out the key to it. It may do it on startup or it may do it after a few other macro's are ran. Can anyone see any problems within this code that might cause such an issue?

    The error I am getting (highlighted in red) is that it cannot view the object properties. So the picture is put in, but it's emplacement cannot be set and the picture cannot be renamed (which must occur for other macros to see it).
    • Pages are not protected
    • The only self automated macro is on workbook open, and it only resizes to view the area depending on the persons resolution.
    • Microsoft Excel 2003


    Sub insertpictureonclick()
    Dim Emplacement As Range
    Dim objImg As Object
    Dim myPicture As Variant
    On Error Resume Next
    ActiveSheet.Shapes("Picture 1").Delete
        ActiveSheet.Shapes("Picture 2").Delete
        ActiveSheet.Shapes("Picture 3").Delete
        ActiveSheet.Shapes("Picture 4").Delete
        ActiveSheet.Shapes("Picture 5").Delete
        
    myPicture = Application.GetOpenFilename _
      ("Pictures (*.gif; *.jpg; *.bmp; *.tif), *.gif; *.jpg; *.bmp; *.tif", _
    , "Select Picture to Import")
    If myPicture = False Then Exit Sub
    
    ActiveSheet.Pictures.Insert (myPicture)
    
    Set Emplacement = Range("M2:S29")
    
    Set objImg = ActiveSheet.DrawingObjects(ActiveSheet.Shapes.Count)
    ActiveSheet.DrawingObjects(ActiveSheet.Shapes.Count).Select
    Selection.Name = "Picture 1"   
    With objImg.ShapeRange
         .LockAspectRatio = msoFalse
         .Left = Emplacement.Left
         .Top = Emplacement.Top
         .Height = Emplacement.Height
         .Width = Emplacement.Width
    End With
    End Sub
    Last edited by vamosj; 05-05-2009 at 01:35 AM.
    Janos S. Vamos
    Data Systems Technician/Fire Controlman PO1(SW/AW)
    US Navy Retired


    Remember, Record Macro can be your friend for figuring out solutions.

    Good or Bad, let me know how I did by clicking on the "Add Reputation" * just to the lower left of here. it only takes a few seconds to let someone know.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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