Ask Your Question
0

find/replace not working for words longer than 15 characters [closed]

asked 2013-01-31 12:42:24 +0200

eelco gravatar image

updated 2015-10-26 03:57:55 +0200

Alex Kemp gravatar image

In the following macro I would like to mark words with more than 15 characters. It just replaces the words with an yellow & But it should replace the word found with itself and make it yellow. Why dows the & not work as it should?

Anybody any ideas? Thanks Eelco

-------------------------------------------------------------------------

sub words
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:GoToStartOfDoc", "", 0, Array())

rem ----------------------------------------------------------------------
dim args2(18) as new com.sun.star.beans.PropertyValue
args2(0).Name = "SearchItem.StyleFamily"
args2(0).Value = 2
args2(1).Name = "SearchItem.CellType"
args2(1).Value = 0
args2(2).Name = "SearchItem.RowDirection"
args2(2).Value = true
args2(3).Name = "SearchItem.AllTables"
args2(3).Value = false
args2(4).Name = "SearchItem.Backward"
args2(4).Value = false
args2(5).Name = "SearchItem.Pattern"
args2(5).Value = false
args2(6).Name = "SearchItem.Content"
args2(6).Value = false
args2(7).Name = "SearchItem.AsianOptions"
args2(7).Value = false
args2(8).Name = "SearchItem.AlgorithmType"
args2(8).Value = 1
args2(9).Name = "SearchItem.SearchFlags"
args2(9).Value = 65536
args2(10).Name = "SearchItem.SearchString"
args2(10).Value = "\<[a-z]{15,}\>"
args2(11).Name = "SearchItem.ReplaceString"
args2(11).Value = "&"
args2(12).Name = "SearchItem.Locale"
args2(12).Value = 255
args2(13).Name = "SearchItem.ChangedChars"
args2(13).Value = 2
args2(14).Name = "SearchItem.DeletedChars"
args2(14).Value = 2
args2(15).Name = "SearchItem.InsertedChars"
args2(15).Value = 2
args2(16).Name = "SearchItem.TransliterateFlags"
args2(16).Value = 1280
args2(17).Name = "SearchItem.Command"
args2(17).Value = 3
args2(18).Name = "Quiet"
args2(18).Value = true

dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args2())


end sub
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-10-26 03:58:07.408463

1 Answer

Sort by » oldest newest most voted
1

answered 2013-01-31 23:40:58 +0200

w_whalley gravatar image

updated 2013-03-04 14:56:27 +0200

I made the following changes to your code and added some lines (this is in LO 3.5.4)

args1(9).Value = "\<[a-z]{15,}"
args1(11).Value = ""
args1(17).Value = 1
rem args1(18).Name = "Quiet"
rem args1(18).Value = true
rem lines below added after first dispatcher.... and ahead of end sub
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Color"
args2(0).Value = 16776960
dispatcher.executeDispatch(document, ".uno:Color", "", 0, args2())
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-01-31 12:42:24 +0200

Seen: 263 times

Last updated: Mar 04 '13