Ask Your Question
0

Macro is now broken

asked 2017-04-21 05:19:59 +0200

LunixTheFirst gravatar image

I am not sure what broke the macro. My machine recently updated to Windows 10 Creator Edition. I also updated LO to version 5.3.2.2.

Here's the macro that used to work:

sub Remove_WT_Unicode_Junk
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 msgbox "running Remove_WT_Unicode_Junk"

rem Replace '+' for scripture references
dim args1(18) as new com.sun.star.beans.PropertyValue
args1(0).Name = "SearchItem.StyleFamily"
args1(0).Value = 2
args1(1).Name = "SearchItem.CellType"
args1(1).Value = 0
args1(2).Name = "SearchItem.RowDirection"
args1(2).Value = true
args1(3).Name = "SearchItem.AllTables"
args1(3).Value = false
args1(4).Name = "SearchItem.Backward"
args1(4).Value = false
args1(5).Name = "SearchItem.Pattern"
args1(5).Value = false
args1(6).Name = "SearchItem.Content"
args1(6).Value = false
args1(7).Name = "SearchItem.AsianOptions"
args1(7).Value = false
args1(8).Name = "SearchItem.AlgorithmType"
args1(8).Value = 0
args1(9).Name = "SearchItem.SearchFlags"
args1(9).Value = 65536
args1(10).Name = "SearchItem.SearchString"
args1(10).Value = "+"
args1(11).Name = "SearchItem.ReplaceString"
args1(11).Value = ""
args1(12).Name = "SearchItem.Locale"
args1(12).Value = 255
args1(13).Name = "SearchItem.ChangedChars"
args1(13).Value = 2
args1(14).Name = "SearchItem.DeletedChars"
args1(14).Value = 2
args1(15).Name = "SearchItem.InsertedChars"
args1(15).Value = 2
args1(16).Name = "SearchItem.TransliterateFlags"
args1(16).Value = 1280
args1(17).Name = "SearchItem.Command"
args1(17).Value = 3
args1(18).Name = "Quiet"
args1(18).Value = true

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

end sub

How do I get this to work?

edit retag flag offensive close merge delete

Comments

BTW: I added { msgbox "running Remove_WT_Unicode_Junk" } to verify that the macro actually runs, and it does. It just doesn't do anything at all. For example in the code above, a "+" sign should be replaced with nothing. Nothing happens, those signs remain, and text is unchanged.

I also found out that when I use a different template the macro works as expected, even with identical text that should be replaced.

LunixTheFirst gravatar imageLunixTheFirst ( 2017-04-21 06:47:22 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2017-04-21 11:20:08 +0200

karolus gravatar image

Hallo

Its a record of find&Replace, record the action again and compare both macros.

My guess: there is some different in line args1(17).Value = ???

edit flag offensive delete link more

Comments

Many thanks, karolus. Looks like I found a bug that I can't reproduce. When I open the document where it wasn't working before, it does work now. I have closed and re-opened Writer in the meantime.

LunixTheFirst gravatar imageLunixTheFirst ( 2017-04-22 03:30:49 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-04-21 05:19:59 +0200

Seen: 20 times

Last updated: 2 days ago