LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel 2007 Beta 2 - Macro Run-time error '424' Object required

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime error '424': Object Required loren.pottinger Excel Discussion (Misc queries) 1 August 28th 06 09:56 PM
"Microsoft Visual Basic runtime error '424' object required". SharonG. Excel Worksheet Functions 0 July 5th 06 01:36 AM
Object required - run time error 424. devorivivere Excel Programming 3 April 10th 04 05:43 PM
Run-time error '424': Object required Phil Bewig Excel Programming 3 February 1st 04 08:38 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


All times are GMT +1. The time now is 11:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"