On 01/20/2012 10:39 AM, paulwhitehurst wrote:
Andrew:
Thank you for your work. I used your last two and both of them worked fine.
The one that searches for the next } is more useful to me. I would like to
figure out how to make it ask to go to the top to continue the search if it
gets to the end of the document, or just stop the macro without opening the
macro editor window.
Paul
So, do these do as you desire? Call findNext.... Notice the difference.
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)
'Inspect oFound
If Not IsEmpty(oFound) AND NOT IsNull(oFound) Then
oFound.setString("")
oDoc.CurrentController.select(oFound)
ElseIf MsgBox("Not found, continue from top?", 4) = 6 Then
findFirstAndRemoveChar()
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) AND NOT IsNull(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: users+help@global.libreoffice.org
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
Context
- Re: [libreoffice-users] Need simple find & replace macro (continued)
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.