Hi all,
First timer here, currently I am learning VBA and I am progressing pretty good if I say so myself (with Google of course:P).
I want to do the following: I want to be able to select multiple shapes and by clicking a button I want to be able to format the selected shapes. I am currently able to do this with one shape selected (see code) but when I select multiple shapes I get my error msgBox.
The Code:
Sub ActiveShape_10()
'PURPOSE: Determine the currently selected shape
Dim ActiveShape As Shape
Dim UserSelection As Variant
'Pull-in what is selected on screen
Set UserSelection = ActiveWindow.Selection
'Determine if selection is a shape I think I have to change something here... but I have no clue what
On Error GoTo NoShapeSelected
Set ActiveShape = ActiveSheet.Shapes(UserSelection.Name)
On Error Resume Next
'Do Something with your Shape variable
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
.Solid
End With
With Selection.ShapeRange.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
End With
Exit Sub
'Error Handler
NoShapeSelected:
MsgBox "You do not have a shape selected!"
End Sub
Heard there is a lot of expertise here so I hope you guys can help me out !!
Thanks in advance,
Grt.
First timer here, currently I am learning VBA and I am progressing pretty good if I say so myself (with Google of course:P).
I want to do the following: I want to be able to select multiple shapes and by clicking a button I want to be able to format the selected shapes. I am currently able to do this with one shape selected (see code) but when I select multiple shapes I get my error msgBox.
The Code:
Sub ActiveShape_10()
'PURPOSE: Determine the currently selected shape
Dim ActiveShape As Shape
Dim UserSelection As Variant
'Pull-in what is selected on screen
Set UserSelection = ActiveWindow.Selection
'Determine if selection is a shape I think I have to change something here... but I have no clue what
On Error GoTo NoShapeSelected
Set ActiveShape = ActiveSheet.Shapes(UserSelection.Name)
On Error Resume Next
'Do Something with your Shape variable
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
.Solid
End With
With Selection.ShapeRange.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
End With
Exit Sub
'Error Handler
NoShapeSelected:
MsgBox "You do not have a shape selected!"
End Sub
Heard there is a lot of expertise here so I hope you guys can help me out !!
Thanks in advance,
Grt.