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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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