MeySo
New Member
- Joined
- Jun 24, 2022
- Messages
- 2
- Office Version
- 365
- 2021
- 2019
- 2016
- 2010
- 2007
- 2003 or older
- Platform
- Windows
- Mobile
Hi,
I'm actually trying to refine our duty schedule which was a real mess when we first started with it.
Currently I'm adding a shape in a defined range within the worksheet using the following:
Sub TextBox_Abwesend()
Dim tboAbw As Shape
With Selection
Set tboAbw = ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, Selection.Left, Selection.Top, Selection.Width, Selection.Height)
UserForm1.Show
tboAbw.DrawingObject.Text = UserForm1.ComboBox1.Value & vbCrLf & UserForm1.TextBox1.Value & ", " & vbCrLf & Application.UserName & ", " & Date
tboAbw.DrawingObject.Font.Name = "Arial"
tboAbw.DrawingObject.Font.Size = 8
tboAbw.DrawingObject.Font.Bold = False
tboAbw.DrawingObject.Font.Color = RGB(250, 250, 250)
tboAbw.ShapeStyle = msoShapeStylePreset9
tboAbw.TextEffect.Alignment = msoTextEffectAlignmentCentered
tboAbw.Line.Weight = 1
tboAbw.OnAction = "ActiveShape"
Unload UserForm1
End With
End Sub
Now a textbox(shape) is created with several entries within the actual worksheet. Now I'd like to have a simple readout possibility for that textbox which seems a little complicated.
Right now i linked following macro to a command button:
Public Sub ActiveShape()
Dim ActiveShape As Shape
Dim UserSelection As Variant
Set UserSelection = ActiveWindow.Selection
On Error GoTo NoShapeSelected
Set ActiveShape = ActiveSheet.Shapes(UserSelection.Name)
On Error Resume Next
MsgBox ActiveShape.TextFrame.Characters.Text, , "Grund"
Exit Sub
NoShapeSelected:
MsgBox "Kein Termin ausgewählt!"
End Sub
Problem with that is clicking the shape doesn't select the shape itself but enables text editing mode instead, so i need to click on the border of the shape again to be able to run that macro.
Therefore I tried to add tboAbw.OnAction = "ActiveShape" in the first macro, but that won't enable the shape selection either and continues with the error handler instead.
Any solutions on how to solve this?
Kind regards,
Daniel
I'm actually trying to refine our duty schedule which was a real mess when we first started with it.
Currently I'm adding a shape in a defined range within the worksheet using the following:
Sub TextBox_Abwesend()
Dim tboAbw As Shape
With Selection
Set tboAbw = ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, Selection.Left, Selection.Top, Selection.Width, Selection.Height)
UserForm1.Show
tboAbw.DrawingObject.Text = UserForm1.ComboBox1.Value & vbCrLf & UserForm1.TextBox1.Value & ", " & vbCrLf & Application.UserName & ", " & Date
tboAbw.DrawingObject.Font.Name = "Arial"
tboAbw.DrawingObject.Font.Size = 8
tboAbw.DrawingObject.Font.Bold = False
tboAbw.DrawingObject.Font.Color = RGB(250, 250, 250)
tboAbw.ShapeStyle = msoShapeStylePreset9
tboAbw.TextEffect.Alignment = msoTextEffectAlignmentCentered
tboAbw.Line.Weight = 1
tboAbw.OnAction = "ActiveShape"
Unload UserForm1
End With
End Sub
Now a textbox(shape) is created with several entries within the actual worksheet. Now I'd like to have a simple readout possibility for that textbox which seems a little complicated.
Right now i linked following macro to a command button:
Public Sub ActiveShape()
Dim ActiveShape As Shape
Dim UserSelection As Variant
Set UserSelection = ActiveWindow.Selection
On Error GoTo NoShapeSelected
Set ActiveShape = ActiveSheet.Shapes(UserSelection.Name)
On Error Resume Next
MsgBox ActiveShape.TextFrame.Characters.Text, , "Grund"
Exit Sub
NoShapeSelected:
MsgBox "Kein Termin ausgewählt!"
End Sub
Problem with that is clicking the shape doesn't select the shape itself but enables text editing mode instead, so i need to click on the border of the shape again to be able to run that macro.
Therefore I tried to add tboAbw.OnAction = "ActiveShape" in the first macro, but that won't enable the shape selection either and continues with the error handler instead.
Any solutions on how to solve this?
Kind regards,
Daniel