Toggle Shadow on currently selected object

RyderS

New Member
Joined
Oct 22, 2015
Messages
4
Hi All,

I'd like to use VBA to toggle a shadow on the currently selected shape... I've tried a few things, but somehow I can't seem to get to the currently selected shape.

Might someone give me a leg up?

Thanks so much!

R
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
this should help, modify to your needs

Code:
Sub ActiveShape()
'PURPOSE: Determine the currently selected shape
'SOURCE: www.TheSpreadsheetGuru.com/the-code-vault


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
  On Error GoTo NoShapeSelected
    Set ActiveShape = ActiveSheet.Shapes(UserSelection.Name)
  On Error Resume Next


'Do Something with your Shape variable
'example toggle

If ActiveShape.Shadow.Type = msoShadow21 Then
ActiveShape.Shadow.Visible = msoFalse
ElseIf ActiveShape.Shadow.Visible = msoFalse Then
ActiveShape.Shadow.Type = msoShadow21
End If


Exit Sub


'Error Handler
NoShapeSelected:
  MsgBox "You do not have a shape selected!"


End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,186
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top