Selasa, 25 September 2012

Re: [ExcelVBA] VBA Dynamic Object reference

 

Hi,

You can reference a newly added shape/object with the count property.

with ActiveSheet.Shapes(ActiveSheet.shapes.count)
.Width = 400
end with

... Should work.. not tested though :-)

HTH
LIsa

Sent: Tue, Sep 25, 2012 2:28 pm
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]

__._,_.___
Recent Activity:
----------------------------------
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