Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
I cannot edit cell format in Excel 2000 (Part of office 2000)! | Excel Discussion (Misc queries) | |||
2nd try --Macro to transfer data in an Excel sheet (2000) in Access 2000 ( code to replace what wizard do) | Excel Programming | |||
Hyperlink in Excel 2000 can't open bookmarked Word 2000 file | Excel Discussion (Misc queries) | |||
Create macro to download access 2000 table to excel 2000 spreadsheet | Excel Programming | |||
Code-signing certificate problems in Excel 2000 with Windows 2000 | Excel Programming |