Hello everybody,
I'm using Excel 2003 and like to write a VBA function which creates a textbox and fill it with some text.
My function looks like this (just the code which is relevant for the creation of the textbox):
When I execute this function from a cell (e.g. A1 = "=CreateBox()") the textbox is created but no text is visible.
After some time I found out that if I copy the code to a Sub() it works fine:
BUT it doesen't work if I call this Sub from a function:
What am I doing wrong?
I'm using Excel 2003 and like to write a VBA function which creates a textbox and fill it with some text.
My function looks like this (just the code which is relevant for the creation of the textbox):
Code:
Function CreateBox()
Dim wsActive As Worksheet
Dim box As Shape
Set wsActive = ActiveSheet
Set box = wsActive.Shapes.AddTextbox(msoTextOrientationHorizontal, 1, 1, 100, 10)
box.TextFrame.Characters.Text = "test"
End Function
After some time I found out that if I copy the code to a Sub() it works fine:
Code:
Sub testsub()
Dim wsActive As Worksheet
Dim box As Shape
Set wsActive = ActiveSheet
Set box = wsActive.Shapes.AddTextbox(msoTextOrientationHorizontal, 1, 1, 100, 10)
box.TextFrame.Characters.Text = "test"
End Sub
Code:
Function testFunct()
Call testsub()
End Function
Last edited: