K
KenCJohnson
I'm trying to make a macro for changing the names of selected shapes...
Public Sub ReNameShape()
Dim Shp As Shape
Dim I As Long
Dim ncShapes As New Collection
For Each Shp In Application.Selection.ShapeRange
ncShapes.Add Item:=Shp
Next
For Each Shp In ncShapes
Shp.Select
Application.ScreenRefresh
Shp.Name = InputBox(prompt:="Current Name:=" & Shp.Name, _
Title:="Rename This Shape", Default:=Shp.Name)
Next Shp
End Sub
The user should select the shapes then run the macro.
If all the selected shapes are still in view when the macro is run then
the user can see which shape is about to have its name changed (the
macro code selects the shape about to have its name changed).
However, if the user scrolled the document when selecting shapes,
causing selected shape(s) to scroll out of view; when the macro is run,
my code, as it stands, won't enable the user to see any off-screen
shapes before changing its name.
The simple cure is for the user to refrain from scrolling when
selecting shapes for name change via my macro.
However, I would prefer the code cause Word to scroll to any off-screen
shapes that have been selected for name change.
My knowledge of the Word object model is not up to this task.
Any assistance would be much appreciated.
Ken Johnson
Public Sub ReNameShape()
Dim Shp As Shape
Dim I As Long
Dim ncShapes As New Collection
For Each Shp In Application.Selection.ShapeRange
ncShapes.Add Item:=Shp
Next
For Each Shp In ncShapes
Shp.Select
Application.ScreenRefresh
Shp.Name = InputBox(prompt:="Current Name:=" & Shp.Name, _
Title:="Rename This Shape", Default:=Shp.Name)
Next Shp
End Sub
The user should select the shapes then run the macro.
If all the selected shapes are still in view when the macro is run then
the user can see which shape is about to have its name changed (the
macro code selects the shape about to have its name changed).
However, if the user scrolled the document when selecting shapes,
causing selected shape(s) to scroll out of view; when the macro is run,
my code, as it stands, won't enable the user to see any off-screen
shapes before changing its name.
The simple cure is for the user to refrain from scrolling when
selecting shapes for name change via my macro.
However, I would prefer the code cause Word to scroll to any off-screen
shapes that have been selected for name change.
My knowledge of the Word object model is not up to this task.
Any assistance would be much appreciated.
Ken Johnson