I am trying to identify a textbox that has been clicked
using shapes.addtextbox i added a number of text boxes
I now wonder if when selected i can recognise that it is a textbox and select the associated cell instead
I am trying to identify a textbox that has been clicked
using shapes.addtextbox i added a number of text boxes
I now wonder if when selected i can recognise that it is a textbox and select the associated cell instead
Place an example of your file
this is the code that generates the textboxes
when the user selects the textbox on the sheet I want to change the selection to the cell identified in the textbox.name![]()
Sub BORROW() 'escape clause If IsEmpty(ActiveCell) Then Exit Sub 'check fo previous borrowing 'continue to borrow Set mydocument = ActiveSheet FontSize = ActiveCell.Font.Size ReducedFont = FontSize * 0.75 crossout = vbRed MarkUp = vbBlack cTop = ActiveCell.Top cLeft = ActiveCell.Left cwidth = ActiveCell.Width cheight = ActiveCell.Height 'Debug.Print "cell width = " & cwidth & " cell height = " & cheight cNudgeLeft = ActiveCell.Left + cwidth / 10 cnudgeUp = ActiveCell.Top - cheight / 20 cBackOff = cwidth / 6 cShoveLeft = cLeft + cwidth * 0.4 cShoveUp = cTop - cheight * 0.4 cNextLeft = cLeft + cwidth - cBackOff 'cross out With mydocument.Shapes.AddTextbox(msoTextOrientationHorizontal, _ cNudgeLeft, cnudgeUp, cwidth, cheight) .Name = ActiveCell.Address & "/" .TextFrame.Characters.Text = "/" .TextFrame.Characters.Font.Size = FontSize .TextFrame.Characters.Font.Color = crossout .Fill.Visible = False .Line.Visible = False '.Line.Visible = msoFalse '.Fill.Transparency = 1 End With 'reduce value With mydocument.Shapes.AddTextbox(msoTextOrientationHorizontal, _ cShoveLeft, cShoveUp, cwidth, cheight) .Name = ActiveCell.Address & "r" .TextFrame.Characters.Text = ActiveCell.Value - 1 .TextFrame.Characters.Font.Size = ReducedFont .TextFrame.Characters.Font.Color = MarkUp .Fill.Visible = False .Line.Visible = False '.Fill.Transparency = 1 End With 'place 1 With mydocument.Shapes.AddTextbox(msoTextOrientationHorizontal, _ cNextLeft, cShoveUp, cwidth, cheight) .Name = ActiveCell.Address & "b" .TextFrame.Characters.Text = "1" .TextFrame.Characters.Font.Size = ReducedFont .TextFrame.Characters.Font.Color = MarkUp .Fill.Visible = False .Line.Visible = False '.Fill.Transparency = 1 End With End Sub
currently I do not know how to identify the selecton of a textbox only that it gains handles when selected on the sheet so some event must be happening.
see image
textbox selected.png
Last edited by incidentals; 07-07-2019 at 09:30 AM.
If these are textboxes created from the Forms toolbar and they have been assigned a macro you can identify them using Application.Caller.
That will give you the name of the control that has called the macro which you can then use to get a reference to the control and all it's properties.
If posting code please use code tags, see here.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks