Search the web
Sign In
New User? Sign Up
thecredit · CREdit text editor
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Find Next Selected Macro   Message List  
Reply | Forward Message #91 of 106 |
Hi,

if anybody finds it handy to search a string with simple selecting it an
press a key, here is the macro (best used with F3 shortcut):
-- snip --
Option Explicit
' (C) 2003 Theodor Willax
' DISCLAIMER:
'
' This software is provided "as is", without any guarantee made as to its
' suitability or fitness for any particular use. It may contain bugs, so
use of
' this tool is at your own risk. The author takes no responsibility for any
' damage whatsoever that may be caused through its use.
'
' FindNextSelected():
' If there is any text selected in the ActiveDocument the next occurence
of this
' string is searched and selected. If EndOfDocument is reached, the search
' starts at the beginning of the ActiveDocument and selects the next
occurence
' of the search string, if the user wants to.
' If no text in the ActiveDocument is selected, nothing is done.
' It is best used with a shortcut to F3 key.
Sub FindNextSelected()

If ActiveWindow.type <> "Text" Then
MsgBox sInfoTextFile
Exit Sub
End If

Dim sSelected, currLine, currCol
sSelected = ActiveDocument.Selection

If sSelected = "" Then
Exit Sub
End If

currLine = ActiveDocument.Selection.CurrentLine
currCol = ActiveDocument.Selection.CurrentColumn
ActiveDocument.Selection.FindText sSelected, dsMatchCase

' If we are at the end of the document, start search at the beginning,
' if the user wants to.
If currLine = ActiveDocument.Selection.CurrentLine _
And currCol = ActiveDocument.Selection.CurrentColumn Then
Dim answer
answer = MsgBox(sQuestionContinue, vbYesNo + vbQuestion, sQuestionTitle)

If answer = vbNo Then
Exit Sub
End If

ActiveDocument.Selection.StartOfDocument
ActiveDocument.Selection.FindText sSelected, dsMatchCase
End If
End Sub

Dim sInfoTextFile, sQuestionContinue, sQuestionTitle

sInfoTextFile = "This macro can only be run when a text editor window
is active."
sQuestionContinue = "Search has reached the end of document." + vbCrLf + _
"Do you want to continue searching from the beginning?"
sQuestionTitle = "Find Next Selected"
-- snap --
Simply safe the code in an .vbs file and add it to your macros. Select
shortcut F3 to execute it. Have fun.

Regards, Theo




Mon Mar 24, 2003 3:39 pm

WillaxTheo@...
Send Email Send Email

Forward
Message #91 of 106 |
Expand Messages Author Sort by Date

Hi, if anybody finds it handy to search a string with simple selecting it an press a key, here is the macro (best used with F3 shortcut): -- snip -- Option...
WillaxTheo@...
Send Email
Mar 24, 2003
3:39 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help