On 01/19/2012 10:39 AM, paulwhitehurst wrote:
I want to migrate my law office from WordPerfect to Libreoffice. My forms
have the } character that I use where I want to input text. I created a
macro in WordPerfect that searches for that character, deletes it, and
leaves the cursor at the position. I've assigned the macro to a key so I
can quickly go through documents.
I'm having difficulty learning how to duplicate this in Libreoffice.
Likewise, I'm having difficulty finding one that already does this.
Help please. Thanks.
Paul
If I were not lacking in time I would provide a better macro than this,
but...... Does this work for you?
sub findAndRemoveChar
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 ----------------------------------------------------------------------
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 = 1
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 = 0
args1(18).Name = "Quiet"
args1(18).Value = true
dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:SwBackspace", "", 0, Array())
end sub
Known issues. (1) This will issue the backspace even if nothing is
found. Grumble, unacceptable. grumble grumble...
OK, I will write one myself... how about one of these...
Sub findNextAndRemoveChar()
Dim oFind
Dim oFound
Dim oDoc
oDoc = ThisComponent
oFind = oDoc.createSearchDescriptor()
With oFind
.SearchString = "}"
End With
oFound = oDoc.FindNext(oDoc.CurrentController.ViewCursor, oFind)
If Not IsEmpty(oFound) Then
oFound.setString("")
oDoc.CurrentController.select(oFound)
End If
End Sub
Sub findFirstAndRemoveChar()
Dim oFind
Dim oFound
Dim oDoc
oDoc = ThisComponent
oFind = oDoc.createSearchDescriptor()
With oFind
.SearchString = "}"
End With
oFound = oDoc.FindFirst(oFind)
If Not IsEmpty(oFound) Then
oFound.setString("")
oDoc.CurrentController.select(oFound)
End If
End Sub
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info: http://www.pitonyak.org/oo.php
--
For unsubscribe instructions e-mail to: [email protected]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted