You have to qualify the objects with the reference to the your instance of
Excel, not Excel itself.
I suppose somewhere you have
Dim XLApp as excel.application
set xlapp=new....
so use
xlapp.WorksheetFunction.CountIf(oxlsheet.....
And qualify ALL the syntax from Excel used in VB6: e.g.
[A6], xlPart, xlFormulas etc.
NickHK
"Prem" wrote in message
...
Hi,
when i use the qualified names for the fucntions it works well in my
system
but fails in the production environment. I tried the following lines
Excel.WorksheetFunction.CountIf(oxlsheet.Range(oxl sheet.Cells(1, 1),
oxlsheet.Cells(1, 256)), rs1.Fields(0).Value) = 0 Then
and this line also throws the same error(ref previous post)
oxlsheet.Cells.Find(What:="'" & rs1.Fields(0).Value & "'", After:=[A1],
LookIn:=xlFormulas, _
LookAt:=xlPart,
SearchOrder:=xlByRows, _
SearchDirection:=xlNext,
MatchCase:=False).Activate
What could be the problem?
--
Premkumar
"NickHK" wrote:
As you are working in VB6, you need to qualify the objects that are not
part
of VB (as you have done with the Fields collection of the Recordset),
otherwise VB does not know which library the objects are from.
You can use the Object Browser to see the object hierarchy. e.g.
XLApp.WorksheetFunction...
where XLApp is you instance of Excel
And Cells belongs to a worksheet. But as Bob says, use a range rather
than
all cells on the required sheet.
NickHK
"Prem" wrote in message
...
When i am using the following line of code in my VB6.0 Program
"If WorksheetFunction.CountIf(Cells, rs1.Fields(0).Value) = 0 Then"
the application always throws the following Error message which is not
understable
"Method '~' of object '~' failed"
Can anyone throw some light on this issue.
--
Premkumar