Page 1 of 1

Excel TOleAuto - Find & replace function ...

Posted: Wed Apr 23, 2008 8:16 am
by Rimantas
Hi !

In workplace changed mine PC and with a new Office 2007 . Sorry , but it seems that CHM files of VBAXL10 is empty ( 2b ) . So I can't to view how Find & Replace function can work . It's needful for me that in TExcelsScript class . Maybe you are using something ? Any sample ?

With best regards and thanks in advance ! Rimantas

Posted: Wed Apr 23, 2008 1:15 pm
by Gale FORd
Don't forget, you can record a macro in Excel then perform your actions and then go back and look at the commands it created.

Posted: Wed Apr 23, 2008 6:20 pm
by Rimantas
Gale FORd wrote:Don't forget, you can record a macro in Excel then perform your actions and then go back and look at the commands it created.
A good advice ! :) Thanks ! I'll look into that . But maybe other person have experience with that ? Because transfer from VBA to FWH syntax is complicated and it tooks some hours tries . So any help it will accelearte process ... :)

I looked into macro - here is a piece of source

Code: Select all

    Selection.Replace What:="QWE", Replacement:="555", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False

Of course , I'll try to convert that to FWH . But I'll thankfull for any help , how to do that .

With best regards ! Rimantas

Posted: Wed Apr 23, 2008 6:57 pm
by Rimantas
Rimantas wrote: I looked into macro - here is a piece of source

Code: Select all

    Selection.Replace What:="QWE", Replacement:="555", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False

Of course , I'll try to convert that to FWH . But I'll thankfull for any help , how to do that .
After some research I created new method for TExcelScript class . Here is a code :

Code: Select all

METHOD FReplace( nCol, cWhat, cReplacement, nLookAt, nSearchOrder, lMatchCase, lMatchByte, cSearchFormat, cReplaceFormat ) CLASS TExcels
   Default nCol         := ::oCell:Column
   Default nLookAt      := 1 // xlWhole = 1 , xlPart = 2
   Default nSearchOrder := 2 // xlByColumns = 2 , xlByRows = 1
   Default lMatchCase   := .f.
   
   ::oSheet:Columns( nCol ).Replace( cWhat, cReplacement, nLookAt, nSearchOrder, lMatchCase )
return( NIL )
With best regards ! Rimantas