'Issue when using a shape as a button to accept user input from a shape text box
Hope somebody can help me with this Excel/VBA issue.
I have recently started replacing my active X controls with shape controls hoping for less issues and better performance, however I've stumbled across a strange issue when trying to accept user input from a shape textbox by clicking on a shape button.
I've setup a simple worksheet to demonstrate the problem, it simply has the following shapes;
- Shape textbox used for input, I have locked the shape and unlocked the text.
- Shape button with text for the button name, I have locked the shaped and locked the text.
When the button is clicked and the macro runs it copies the text from the textbox to cell A1
Note: I have protected the sheet except for cell A1
I want the user to input some text into the textbox then immediately click on the button to accept the input, the button will run a macro which will do something with the text.
I've discovered the macro only works when the outside area of the button is clicked, it won't work when the user clicks near the text which is embedded on the button and takes up most of the center area of that button. Also when I hover over the button the mouse pointer changes to a move pointer where text isn't present and for the area with the text it changes to a text pointer.
If I click out of the input text box first into a worksheet cell before clicking the button then it works as expected and the mouse pointer shows the expected link pointer.
Below is the code assigned for the button macro;
Sub Test()
Range("A1") = Sheet1.Shapes("TextBox 1").TextFrame.Characters.Text
End Sub
Any help would be greatly appreciated
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
