Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Below is the code I use in Microsoft Word to preserve my Search/Replace
settings when I run VBA that uses Search/Replace and would normally leave the settings changed. It doesn't look as easy in Excel. Is there a way to obtain the settings, or at least the search string? If so, I guess a clumsy way to restore them would be to open a temporary window and do an actual Find using the original string and other settings, then close the window. But I expect there's a more elegant way. Dan Williams danwPlanet ________________________________________________ Call RememberFindReplaceSettings("Memorize") ' Find/Replace code goes here. Call RememberFindReplaceSettings("Restore") Sub RememberFindReplaceSettings(myMode As String) Static myOldFindText As String Static myOldReplText As String Static myOldDirectio As Boolean Static myOldWrapping As Integer Static myOldFormatNo As Boolean Static myOldMatchCas As Boolean Static myOldWholWord As Boolean Static myOldWildcard As Boolean Static myOldSounLike As Boolean Static myOldAllWdFms As Boolean Static myOldFindStyl As String Static myOldReplStyl As String With Selection.Find If myMode = "Memorize" Then myOldFindStyl = .Style myOldReplStyl = .Replacement.Style myOldFindText = .Text myOldReplText = .Replacement.Text myOldDirectio = .forward myOldWrapping = .Wrap myOldFormatNo = .Format myOldMatchCas = .MatchCase myOldWholWord = .MatchWholeWord myOldWildcard = .MatchWildcards myOldSounLike = .MatchSoundsLike myOldAllWdFms = .MatchAllWordForms ElseIf myMode = "Restore" Then If myOldFindStyl < "" Then .Style = myOldFindStyl If myOldReplStyl < "" Then .Replacement.Style = myOldReplStyl .Text = myOldFindText .Replacement.Text = myOldReplText .forward = myOldDirectio .Wrap = myOldWrapping .Format = myOldFormatNo .MatchCase = myOldMatchCas .MatchWholeWord = myOldWholWord .MatchWildcards = myOldWildcard .MatchSoundsLike = myOldSounLike .MatchAllWordForms = myOldAllWdFms End If End With End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Trying to restore all default settings | Excel Worksheet Functions | |||
How do I restore the default settings in Excel 2003? | Setting up and Configuration of Excel | |||
find and replace - replace data in rows to separated by commas | Excel Worksheet Functions | |||
How do I restore my original excel settings to default? | Excel Discussion (Misc queries) | |||
hide and restore personal display settings in excel menu | Excel Programming |