Monday, 15 August 2011

vba - How to rename the selected shape in Excel -



vba - How to rename the selected shape in Excel -

if select shape, such chart or text box, how can rename in vba? have nice little sub , form in powerpoint this:

sub shapename() if not activewindow.selection nil if activewindow.selection.type = ppselectionshapes nameform.namebox.text = activewindow.selection.shaperange.name nameform.show if not nameform.bcancel activewindow.selection.shaperange.name = nameform.namebox.text end if end if end if end sub

how can accomplish same in excel? activewindow.selection object different. can't work out how navigat selection selected shape. if shape selected chart object, source cells selected, , want ignore , rename shape.

here little example:

sub arosebyanyothername() activesheet.shapes(1).select selection.name = "myredrose" end sub

edit#1:

if know selected object chart use:

sub arosebyanyothername() activechart.parent.name = "myredrose" end sub

vba excel-vba

No comments:

Post a Comment