Simular el efecto de presionar un botón
Tengo una macro asignada a una forma de rectángulo que va a la siguiente hoja de mi libro.
Estoy tratando de agregar un efecto de presión hacia abajo y hacia arriba a este rectángulo.
Cuando uso este código, el rectángulo solo se presiona hacia abajo, luego se activa la siguiente hoja y, si vuelvo a la hoja anterior, se libera el rectángulo.
Lo que necesito es que el rectángulo se presione hacia abajo y luego se suelte antes de pasar a la siguiente hoja.
¿Alguna sugerencia?
Gracias de antemano.
Dim MyButton As Shape
Dim oHeight, oWidth, cHeight, cWidth As Double
Dim oTop, oLeft As Long
Public Sub PressButton()
Set MyButton = ActiveSheet.Shapes(Application.Caller)
With MyButton
'Record original button properties.
oHeight = .Height
oWidth = .Width
oTop = .Top
oLeft = .Left
'Button Down (Simulate button click).
.ScaleHeight 0.9, msoFalse
.ScaleWidth 0.9, msoFalse
cHeight = .Height
cWidth = .Width
.Top = oTop + ((oHeight - cHeight) / 2)
.Left = oLeft + ((oWidth - cWidth) / 2)
End With
'Set MyButton variable to Nothing to free memory.
Set MyButton = Nothing
End Sub
Public Sub ReleaseButton()
Set MyButton = ActiveSheet.Shapes(Application.Caller)
With MyButton
'Button Up (Set back to original button properties).
.Height = oHeight
.Width = oWidth
.Top = oTop
.Left = oLeft
End With
'Set MyButton variable to Nothing to free memory.
Set MyButton = Nothing
End Sub
Public Sub NextPage()
PressButton
Application.Wait (Now + TimeSerial(0, 0, 1))
ReleaseButton
Dim ws As Worksheet
Set ws = ActiveSheet
Do While Not ws.Next.Visible = xlSheetVisible
Set ws = ws.Next
Loop
With ws.Next
.Activate
.Range("A1").Select
End With
End Sub