OLE automation with Excel

Hello,

I try to find some information in an excel sheet but OLE Automation is not succesful.

Here is my script : I want to find the string name in column B of the Excel sheet.

OleAutoObj objExcel, objExcelSelection, objRange
OleAutoArgs args = create

int FindRow (string name)
{
//Find in column B
put(args, "B:B")
checkRes(oleGet(objSheet, "Columns", args, objColumns))
checkRes(oleMethod(objColumns, cMethodSelect))

//in VBA : Selection.Find(What:= name).Activate
checkRes(oleGet(objExcel, "Selection", objExcelSelection ) )
if (objExcelSelection !== null) {
clear (args)
put(args, "What",name)
checkRes(oleGet(objExcelSelection, "Find", objRange)) 
checkRes(oleMethod(objRange, "Item", args, objCell))
checkRes(oleMethod(objCell, "Activate"))
}
}

I'm not sure about the Find method "checkRes(oleGet(objExcelSelection, "Find", objRange))" called here. 

Is there a mistake about classes and objects ?!?

 

Please can someone help me, 


Estebell - Tue Dec 08 10:11:09 EST 2015

Re: OLE automation with Excel
Mathias Mamsch - Tue Dec 08 10:17:55 EST 2015

Start by coming up with a working VBA code of what you want to do ...

You are trying to use "Excel.Selection.Find" here which seems weird and you are using "Find" as a property (oleGet), while it is a method (use oleMethod). You are also not passing parameters.

Once you have a working VBA it is easier to translate to DXL. Make sure you don't mess up properties with methods and vice versa. Look at the excel reference if you are unsure:

https://msdn.microsoft.com/EN-US/library/office/ff839746.aspx

Regards, Mathias