We will be migrating from Ask to Discourse on the first week of August, read the details here

Ask Your Question

how to write macro programming? [closed]

asked 2013-11-12 20:40:23 +0200

altair gravatar image

Hello! Please, can someone help me how to write PROGRAM (macro-edit) which recognises certain (decimal) number in the text?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2015-11-14 14:50:37.069354

1 Answer

Sort by » oldest newest most voted

answered 2013-11-13 16:28:04 +0200

JohnSUN gravatar image

I don't quite understand your question, but a macro to search for numbers in the text of the document can be as

Sub searchDigitsInText
Dim oSDescriptor As Variant ' Search descriptor
Dim oSearchResult As Variant ' Result of "Find all"
Dim nCount As Long  ' Count of results
Dim i As Long   ' Index
Dim s As String ' String to message
    oSDescriptor = ThisComponent.createSearchDescriptor()
    oSearchResult = ThisComponent.findAll(oSDescriptor)
    nCount = oSearchResult.getCount()
    If nCount = 0 Then
        MsgBox("Not found any digits in this text")
        S="Found " + nCount+ " values:" + Chr(10)
        For i = 0 to nCount-1
            S = S + oSearchResult.getByIndex(i).getString() + " "
        Next i
End Sub
edit flag offensive delete link more


Thanks!!! Please, how can we make macro searching 3-places numbers (abc) like 445, 983 etc?

Sorry, not english, tryinng in teh meantime!!!

altair gravatar imagealtair ( 2013-11-14 14:24:08 +0200 )edit

if we have 3 numbers in the text nCount =3???

altair gravatar imagealtair ( 2013-11-14 14:25:16 +0200 )edit

Question Tools

1 follower


Asked: 2013-11-12 20:40:23 +0200

Seen: 650 times

Last updated: Nov 13 '13