Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have an existing macro that works just fine in Excel 2003, however it
doesn't want to run when opened in 2007 Beta 2. I get an object required error... any ideas on how I can correct this are greatly appreciated. The error is generated on line 7 - "Set p = ActiveSheet.Pictures.Insert(PictureFileName) Code: Sub InsertPictureInRange(PictureFileName As String, TargetCells As Range) ' inserts a picture and resizes it to fit the TargetCells range Dim p As Object, t As Double, l As Double, w As Double, h As Double If TypeName(ActiveSheet) < "Worksheet" Then Exit Sub If Dir(PictureFileName) = "" Then Exit Sub ' import picture Set p = ActiveSheet.Pictures.Insert(PictureFileName) ' determine positions With TargetCells t = .Top l = .Left w = .Offset(0, .Columns.Count).Left - .Left h = .Offset(.Rows.Count, 0).Top - .Top End With ' Get Picture Height and Width Dim PicHt PicHt = p.Height Dim PicWid PicWid = p.Width ' position picture with Auto-aspect Correction With p ..Top = t ..Left = l If PicHt = PicWid Then ..Width = PicWid * (h / PicHt) ..Height = PicHt * (h / PicHt) Else ..Width = PicWid * (w / PicWid) ..Height = PicHt * (w / PicWid) End If End With Set p = Nothing End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Runtime error '424': Object Required | Excel Discussion (Misc queries) | |||
"Microsoft Visual Basic runtime error '424' object required". | Excel Worksheet Functions | |||
Object required - run time error 424. | Excel Programming | |||
Run-time error '424': Object required | Excel Programming | |||
Syntax Error Runtime Error '424' Object Required | Excel Programming |