Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA - Insert text into textbox error

Status
Not open for further replies.

numcrun

Programmer
Mar 7, 2003
8
NZ
When trying to insert text into a text box (a standard text box from the drawing toolbar) using VBA I sometimes get the error message "-2147417848 method 'Insert' of Object 'Characters' failed." The code is below:


Sub warningtext_OWN_ARREARS_NO_PROPERTY_ADD(textboxname)

startpoint = Len(Range("a1")) + 2
ActiveSheet.Shapes(textboxname).Select
Selection.Characters(Start:=startpoint, Length:=1).Insert _
Chr(10) & "THIS TENANT HAS NO BOND, AND IS IN ARREARS. " & _
"THEY HAVE NO PROPERTY TO SEIZE, SO SHOULD BE EVICTED. IF THEY LEAVE TODAY, YOU WOULD LOSE " & _
Format(-1 * Range("h13"), "$0.00") & " PLUS ANY SHOP ACCOUNT." + Chr(10)

textboxname is a string with value "Text Box 4". All textboxes have this name.
This error occurred 3 times today, but I cannot get it to repeat at will by rerunning the code. startpoint is 15 for what it's worth.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top