Find() and Replace() in Excel 2007 not working.

T

thoward37

Hi,

My program needs to find any white text in an Excel Worksheet andset it's
color to black. This is done prior to a automated printout, in order to make
sure the white text shows up in the print out.

This has worked fine until just recently. The code I've been using is (VB6):

Dim oSheet as Object

oSheet.Application.FindFormat.Clear
oSheet.Application.FindFormat.Font.ColorIndex = 2

oSheet.Application.ReplaceFormat.Clear
oSheet.Application.ReplaceFormat.Font.ColorIndex = 1

oSheet.Cells.Replace What:="", Replacement:="", SearchFormat:=True,
ReplaceFormat:=False



In a simple example, make an Excel file with one cell that has black text,
and one cell with white text. It should find the white text, and change it's
color to black.

I upgraded Office to 2007 from 2003. Under 2003 everything worked as
expected. Under 2007, everything works fine with 2003 documents (xls), but
NOT with 2007 documents (xlsx). The documents are identical, for all intents
and purposes, and I am able to find the text using the same technique via the
UI. I have inspected the cell and the cell has ColorIndex of 2, and should be
found, ut it is not.

Using Range.Find() or Range.Replace() with SearchFormat set to True, never
finds this cell, even though it should.

Can anyone explain why that is? Is there a difference in 2007 that effects
searching by format?

Thanks,
Troy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top