Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default Bug with SelLength? (Excel 2000)

Greetings,
In order to learn how to use VBScript's regular expression object, I
wrote an Excel program that has a user form with several textboxes. You
enter text in one, and a regEx in another, and (optionally) a
replacement expression in a third then press a command button which
will find matches, and hightlight them. It works (almost) perfectly.
The problem is when I use multiline mode and try to match an expression
that spans several lines.

For example, if I enter

This is (a test) I hope it works

and try it against the regex \([\s\S]*\), it highlights (a test), as
expected, but if I type

This
is
(
a
t
e
s
t
) I hope it works

with the same regEx, much of "I hope" is highlighted as well. It seems
that SelLength is ignoring \n or \r or both.
At the very least, this is somewhat undocumented behavior.

By the way, the offending code snippet is

Sub Highlight(myMatch As Match)
Dim i As Integer, n As Integer

i = myMatch.FirstIndex
n = myMatch.Length

tbText.SetFocus
tbText.SelStart = i
tbText.SelLength = n
End Sub

I guess I'll have to write a more complicated sub which starts at
SelStart and steps through the characters one at a time using Mid and
counting the number of line breaks so I can adjust SelLength
appropriately, unless there is a simple work-around I am overlooking.

-John Coleman

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
I cannot edit cell format in Excel 2000 (Part of office 2000)! Brett Excel Discussion (Misc queries) 1 April 12th 06 05:58 PM
2nd try --Macro to transfer data in an Excel sheet (2000) in Access 2000 ( code to replace what wizard do) André Lavoie Excel Programming 0 September 27th 05 01:50 PM
Hyperlink in Excel 2000 can't open bookmarked Word 2000 file DCheslock Excel Discussion (Misc queries) 1 May 5th 05 10:46 PM
Create macro to download access 2000 table to excel 2000 spreadsheet Tushar[_2_] Excel Programming 3 October 21st 04 02:44 PM
Code-signing certificate problems in Excel 2000 with Windows 2000 Aaron Queenan Excel Programming 0 May 6th 04 11:35 AM


All times are GMT +1. The time now is 02:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"