PC Review


Reply
Thread Tools Rate Thread

255 char limit on TextBox

 
 
ep
Guest
Posts: n/a
 
      8th Jul 2008
Hi,

I'm trying to add a series of long strings to a textbox in Excel 2003 using
C# automation like so, but I'm getting blank text boxes:

largeTxt.TextFrame.Characters(missing, missing).Text = ...

I know there's a 255 character limit on the text box, but is there any way
around this? I've tried using the Insert method, and setting explicit start
and length values, but nothing has worked.

Any suggestions? Thanks.
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      8th Jul 2008
From another post -

If your string is over 255 need to insert characters into the textframe in
chunks of less than 255 at a time.

Sub test()
Dim j As Long
Dim sPart$, sText$
Dim shp As Shape

sPart = Application.Rept("x", 37) & "40 "
For j = 1 To 25
sText = sText & sPart
Next
MsgBox Len(sText)
Set shp = ActiveSheet.Shapes.AddTextbox(1, 99#, 9#, 450#, 210#)

With shp
j = 1
Do While j < Len(sText)
sPart = VBA.Strings.Mid(sText, j, 250)
.TextFrame.Characters(j).Insert String:=sPart
j = j + 250
Loop
End With

End Sub

Obviously this is VBA but I imagine you can adapt to C#

Regards,
Peter T

PS Off topic Is it only me or or has Google Groups almost given up its
search capability. Fortunately normal Google works OK and I can find my old
posts in mirror servers of this ng.



"ep" <(E-Mail Removed)> wrote in message
news:94325CBA-25F0-4C5E-BFF6-(E-Mail Removed)...
> Hi,
>
> I'm trying to add a series of long strings to a textbox in Excel 2003

using
> C# automation like so, but I'm getting blank text boxes:
>
> largeTxt.TextFrame.Characters(missing, missing).Text = ...
>
> I know there's a 255 character limit on the text box, but is there any way
> around this? I've tried using the Insert method, and setting explicit

start
> and length values, but nothing has worked.
>
> Any suggestions? Thanks.



 
Reply With Quote
 
ep
Guest
Posts: n/a
 
      8th Jul 2008
Well holy crap, that worked. Thanks for the help.

I tried something similar, but I must have had my indexes off or something.
Great job.
 
Reply With Quote
 
ep
Guest
Posts: n/a
 
      8th Jul 2008
And if anyone else is interested, here's my c# translation:

int j = 0;
while (j < sText.Length)
{
if (j + 250 <= sText.Length)
sPart = sText.Substring(j, 250);
else
sPart = sText.Substring(j);

txtBox.TextFrame.Characters(j, missing).Insert(sPart);
j += 250;
}
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to permanently delete char char char char style in MS Word? =?Utf-8?B?Q3Jpcw==?= Microsoft Word Document Management 6 12th Jun 2011 09:47 PM
MultiLine textBox - limit num of char on each line =?Utf-8?B?R2lkaQ==?= Microsoft C# .NET 2 16th Nov 2007 09:01 PM
How do I limit input-length (char by char) into a Memo Field =?Utf-8?B?TkpT?= Microsoft Access VBA Modules 2 17th Nov 2004 04:29 PM
Limit to 50 char only singkit Microsoft Excel Programming 2 2nd Apr 2004 01:34 AM
dsn limit of 32 char when using - Ewan Microsoft Windows 2000 Developer 0 28th Aug 2003 06:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:17 PM.