LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Determine Find/Replace settings and then restore them?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to restore all default settings Aria Etriano Excel Worksheet Functions 1 December 7th 06 08:58 PM
How do I restore the default settings in Excel 2003? MorAnco Setting up and Configuration of Excel 2 June 28th 06 06:57 AM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM
How do I restore my original excel settings to default? Patsy Excel Discussion (Misc queries) 1 February 14th 05 01:46 AM
hide and restore personal display settings in excel menu Mark[_17_] Excel Programming 0 February 20th 04 07:22 AM


All times are GMT +1. The time now is 09:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"