Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Range.Replace - Supress Not found message? 1

Status
Not open for further replies.

lameid

Programmer
Jan 31, 2001
4,212
US
I am automating Excel and the Excel Applciation is not visible.

XLRange is an Excel Range object. "|hash|" does not always occur which produces a message that I would rather surpress... "Microsoft Excel Cannot find any data to replace. Check if you search formatting and criteria are defined correctly. If you are sure that matching data exists in this workbook, it may be on a protected sheet. Excel cannot replace data on a protected worksheet."

Code:
XLRange.Replace What:="|hash|", Replacement:="#", LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False

What if anything can I do to surpress the message?

Thanks.
 


hi,

FIRST do a Find, like...
Code:
dim rFound as range

set rFound = XLRange.Find("|hash|")

if not rFound is nothing then
  'now do your replace
end if


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
a message that I would rather surpress
Did you try to set the DisplayAlerts property to False ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I am not that familar with the Excel Object models... I suspected there was a way to turn off messages. Thanks PHV!
 
Can I get you guys to take a peek over at another Excel automation issue I am having out of the same procedure?

thread705-1680024
 
I did figure out the second issue or the linked thread above.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top