ChuckDrago
Active Member
- Joined
- Sep 7, 2007
- Messages
- 470
- Office Version
- 2010
- Platform
- Windows
Hi everyone,
I found a neat macro to simulate a button being depressed when using graphic elements acting as buttons, authored by Ryan Wells. (Simulate a Button Click with Rectangle Shape - wellsr.com). It uses 3D beveling and a timer to simulate the depression, very efficiently. In order to apply the effect, you must precede the code for the intended action by a call to Ryan's macro, because it uses an Application.Caller statement that needs to know to which graphic should the effect be applied.
And That is the root cause of the problem I am asking you to help on.
Once I completed the application of Ryan's code to a bunch of graphic pseudo-buttons in my app, I saved the work. From that point, every new instantiation of my work bombs out, error 2023 and message "The item with the specified name was not found".
Here are the beginning lines of Ryan's macro, with the offending line being indicated
<code/>Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub SimulateButt*******()
Dim vTopType As Variant
Dim iTopInset As Integer
Dim iTopDepth As Integer
'Record original button properties
With ActiveSheet.Shapes(Application.Caller).ThreeD '<<< This is the error line
vTopType = .BevelTopType
iTopInset = .BevelTopInset
iTopDepth = .BevelTopDepth
End With
</code>
If I am not mistaken, the compiler fails to find an object (application.caller) active and errors out. The funny thing is that if you reset the error, then all graphic-buttons work as intended and without any problems.
How do I overcome this issue of error upon instantiation?
Thanks in advance.
Chuck
I found a neat macro to simulate a button being depressed when using graphic elements acting as buttons, authored by Ryan Wells. (Simulate a Button Click with Rectangle Shape - wellsr.com). It uses 3D beveling and a timer to simulate the depression, very efficiently. In order to apply the effect, you must precede the code for the intended action by a call to Ryan's macro, because it uses an Application.Caller statement that needs to know to which graphic should the effect be applied.
And That is the root cause of the problem I am asking you to help on.
Once I completed the application of Ryan's code to a bunch of graphic pseudo-buttons in my app, I saved the work. From that point, every new instantiation of my work bombs out, error 2023 and message "The item with the specified name was not found".
Here are the beginning lines of Ryan's macro, with the offending line being indicated
<code/>Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub SimulateButt*******()
Dim vTopType As Variant
Dim iTopInset As Integer
Dim iTopDepth As Integer
'Record original button properties
With ActiveSheet.Shapes(Application.Caller).ThreeD '<<< This is the error line
vTopType = .BevelTopType
iTopInset = .BevelTopInset
iTopDepth = .BevelTopDepth
End With
</code>
If I am not mistaken, the compiler fails to find an object (application.caller) active and errors out. The funny thing is that if you reset the error, then all graphic-buttons work as intended and without any problems.
How do I overcome this issue of error upon instantiation?
Thanks in advance.
Chuck