Andrew Douglas Pitonyak <[EMAIL PROTECTED]> skrev den Sun, 10 Apr 2005 00:13:50 -0400:

<snip>
The following properties are supported:
STRING  ReplaceString
BOOL  SearchBackwards = False
BOOL  SearchByRow = False
BOOL  SearchCaseSensitive = False
BOOL  SearchRegularExpression = False
BOOL  SearchSimilarity = False
INTEGER  SearchSimilarityAdd = 2
INTEGER  SearchSimilarityExchange = 2
BOOL  SearchSimilarityRelax = False
INTEGER  SearchSimilarityRemove = 2
STRING  SearchString
BOOL  SearchStyles = False
INTEGER  SearchType = 0
BOOL  SearchWords = False

Are those values, mentioned above (for example SearchByRow=False), the default values, so if I don't mention them in my code, their values will be like those above?


In my free macro document, I mention the SearchType. 0 means search the formula and 1 means search the value. I have not been able to find this documented any place else. I do not know off hand why I knew this so that I could document this. Oh yes, if you have my book, you will notice that in version 1.0.x, the SearchWords thing was not working.

I wonder if SearchType=2 means "search in notes"... I haven't had any time to test that yet... and I don't need that option at the moment...


You say that you want to search ONLY a range and NOT the entire sheet. Here is a little hint that I have not completely verified...

oSheet.getCellRangeByName("A1:B2").createSearchDescriptor()

This is great if it works! However, I just made a simple test which indicated that it does not:


Sub SearchTest
        Dim Doc, Sheet, CellRange, Descriptor, Found As Object

        Doc=StarDesktop.CurrentComponent
        Sheet=Doc.Sheets.getByName("MySheet")
        CellRange=Sheet.getCellRangeByName("H3:H1000")

        Descriptor=CellRange.createSearchDescriptor()
        With Descriptor
                .SearchBackwards=False
                .SearchByRow=False
                .SearchCaseSensitive=True
                .SearchRegularExpression=False
                .SearchSimilarity=False
                .SearchString="Blah blah blah"
                .SearchStyles=False
                .SearchType=1 ' Search values
                .SearchWords=True
        End With
        Found=Sheet.findFirst(Descriptor)
        Doc.currentController.select(Found)
        Print Found.getString()
End Sub

I entered the string "Blah blah blah" in C10 and H19 on the sheet "MySheet". If it works like expected, H19 should be selected and a message containing the search value should occur. Well, the message indicates that the search string was actually found, but C10 is highlighted, not H19.

So I started to experiment. The first thing I did was obvious:

"Found=Sheet.findFirst(Descriptor)" was replaced by "Found=CellRange.findFirst(Descriptor)"

Now it works and now I actually think I understand HOW it works. H19 is highlighted, just like I want it to and I feel very happy!

So I replace "Descriptor=CellRange.createSearchDescriptor()" by "Descriptor=Sheet.createSearchDescriptor()", just to see if it still works the same way, and it does!

So obviously your hint was not 100% correct, BUT it helped me anyway! It made me think...


So this is what I was looking for:

Sub SearchTest
        Dim Doc, Sheet, CellRange, Descriptor, Found As Object

        Doc=StarDesktop.CurrentComponent
        Sheet=Doc.Sheets.getByName("MySheet")

        Descriptor=Sheet.createSearchDescriptor()
        With Descriptor
                .SearchBackwards=False
                .SearchByRow=False
                .SearchCaseSensitive=True
                .SearchRegularExpression=False
                .SearchSimilarity=False
                .SearchString="Blah blah blah"
                .SearchStyles=False
                .SearchType=1 ' Search values
                .SearchWords=True
        End With
        CellRange=Sheet.getCellRangeByName("H3:H1000")
        Found=CellRange.findFirst(Descriptor)
        Doc.currentController.select(Found)
        Print Found.getString()
End Sub

Thank you very much for your help!


Best regards


Johnny

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to