Micro Focus QTP (UFT) Forums
Excel Find causes syntax error at runtime - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Excel Find causes syntax error at runtime (/Thread-Excel-Find-causes-syntax-error-at-runtime)



Excel Find causes syntax error at runtime - m336fnr - 02-09-2011

Hoping somebody can help out here. I've opened an excel file in a qtp test and want to execute a find method on a range of cells. I can call find with just one paramater, the search string like this:

myRange.Find("some text")

and it returns the result fine. Problem is that if "some text" is in the spreadsheet as :

some text plus more text
and
some text

Then this method will return the first occurence on the basis that its a partial match. I want to return exact matches only.

So, looking at the signature of the Find method as supplied in a drop down list in QTP when I start typing Find( it looks like it accepts a param LookAt:=xlWhole. In fact if I generate a macro in excel it does indeed give me the following :

Set r = appexcel.Range("B9:B2385").Find("some text",,,lookAt:=xlWhole,,,,,)

So, when I try calling this in QTP it gives a syntax error both in QTP and at runtime. I've tried all manner of combinations here but the Find method will not accept more that a simple string. Any help much appreciated.