How do I limit the text in a bookmark

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Lynn Taylor (anonymous_at_discussions.microsoft.com)
Date: 02/25/04


Date: Wed, 25 Feb 2004 08:29:53 -0800

You can use the following vba.

Dim sString As String
Dim iCount As Integer

sString = Selection.text
iCount = Selection.Characters.Count

If iCount > 10 Then
    sString = Left(sString, 10)
End If
Selection.TypeText text:=sString
End Sub

Select the text in your bookmark, then run the code. It
counts the amount of characters in your string, and if
there are more than x amount, it just takes the first x
mount from the left and replaces the entire string with
just that amount of characters. You can change the
characters to words if you wish, so it will word.count.

The example above uses 10 characters but you can change
this to what you want.

Hope this is useful.
>-----Original Message-----
>I put a bookmark in a cell in a table.
>The cell has a standard width, can't get any wider.
>
>How do I limit my bookmark to just one line of text?
>Can I detect Cr or something.
>
>All I want is one line of text in my bookmark and thats
it.
>
>Hope you can help me.
>
>Jens, Denmark
>.
>



Relevant Pages

  • Re: count occurences of font color
    ... cell.Characters(character position, number of characters) ... Does this establish i as the length of the text string in the cell? ... Dim iCount As Long, i as Long ...
    (microsoft.public.excel.programming)
  • Re: Data data from a Data Table
    ... I hadn't come back to check for posts on this after your pseudocode was ... I may end up using that pseudocode to present a report or something as I get ... Public Function fBuildSQL(strIN As String) As String ... Dim iCount As Long ...
    (microsoft.public.access.modulesdaovba)
  • Re: Bounding Combo Box to a database in VB6
    ... Dim rs As DAO.Recordset, sRecordset As String ... Dim iCount As Long, i As Long ... On Error Goto FillComboErr ...
    (microsoft.public.vb.general.discussion)
  • Re: Heres a "CASE" statement with strings... sorta.
    ... constructing the constant list and string list. ... 'First' = sString then begin doThis; exit;end;if ... to synchronize two or three lists for every change in the ...
    (alt.comp.lang.borland-delphi)
  • Re: =?ISO-8859-15?Q?Verschl=FCsseln_von_Daten?=
    ... Dein Code ist leider etwas undurchsichtig... ... As String = "") As Byte ... Dim sString As String = prv_key & sZusVersch ... Möglichkeit die Zeichenfolge zunächst mittels SHA256 zu kodieren ...
    (microsoft.public.de.german.entwickler.dotnet.vb)