Hi Steve
You don't need the Selects, this will work for you :-
ActiveSheet.Shapes(1).Width = 400
Also you might want to test ActiveSheet.Shapes.Count first.
Regards
Derek +++.
>________________________________
> From: steven.eckley <steven.eckley@accenture.com>
>To: ExcelVBA@yahoogroups.com
>Sent: Tuesday, 25 September 2012, 13:26
>Subject: [ExcelVBA] VBA Dynamic Object reference
>
>
>
>Hi I have this basic Macro. Pretty much what it does is it selects a image pasted on the active worksheet, and then adjusts the width of the image. Images are inserter by copy & pasting from picture editor.
>
>The problem is if you delete the current image and paste a new one onto the same worksheet tab, the object item number "3" in the example below changes and the macro does not work. How can i make the item number a variable so that the macro will work for any object in the sheet. There is always only one image on a tab
>
>' Macro2 Macro
>'
>ActiveSheet.Shapes.Range(Array("Object 3")).Select
>ActiveSheet.Shapes("Object 3").Width = 400
>Range("A25").Select
>End Sub
>
>Any help you can provide will be much appreciated as i know very little about vba
>
>Thanks
>
>
>
>
>
[Non-text portions of this message have been removed]
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
Tidak ada komentar:
Posting Komentar