hello everybody,
I have OLE tables in my document, and would like to get the content of the cell x = 1,y = 1 of the table.
I canot find the method to do that.
Does anyone know a way to do that ?
thanks
jbjacques - Wed Jun 13 05:44:53 EDT 2012 |
|
Re: Get a specific cell of a OLE Word table jbjacques - Wed Jun 13 09:59:26 EDT 2012
Hello,
After investigation, I am stopped at this point :
oleGet(objDoc, "Application", objApp)
const int rowNo = 0
const int cellNo = 0
OleAutoArgs objArgBlock = create
OleAutoObj objCelljb
clear objArgBlock
put(objArgBlock, rowNo)
put(objArgBlock, cellNo)
oleMethod(objApp, "Cells", objArgBlock, objCelljb)
The trouble is that objCelljb is null, does anybody have an idea concerning this trouble ?
|
|
Re: Get a specific cell of a OLE Word table David_G_Bond - Wed Jun 13 14:43:06 EDT 2012 jbjacques - Wed Jun 13 09:59:26 EDT 2012
Hello,
After investigation, I am stopped at this point :
oleGet(objDoc, "Application", objApp)
const int rowNo = 0
const int cellNo = 0
OleAutoArgs objArgBlock = create
OleAutoObj objCelljb
clear objArgBlock
put(objArgBlock, rowNo)
put(objArgBlock, cellNo)
oleMethod(objApp, "Cells", objArgBlock, objCelljb)
The trouble is that objCelljb is null, does anybody have an idea concerning this trouble ?
You need to get the Table object and apply the Cell method to the table. If there is only one table, you get the first table from the Tables collection. Then select the cell and get the text from the selection object. There may be a more efficient way to do this. The following snippet is untested, but should be close. Make sure you declare all variables first.
oleGet(objDoc, "Tables", objTables)
clear(objArgBlock)
put(objArgBlock, 1)
oleMethod(objTables, "Item", objArgBlock, objTable)
clear(objArgBlock)
put(objArgBlock, rowNo)
put(objArgBlock, ColNo)
oleMethod(objTable, "Cell", objArgBlock, objCell)
oleMethod(objCell, "Select")
oleGet(objWord, "Selection", objSel) // objWord is Word application object
oleGet(objSel, "Text", sCellText)
|
|
Re: Get a specific cell of a OLE Word table jbjacques - Thu Jun 14 03:45:55 EDT 2012 David_G_Bond - Wed Jun 13 14:43:06 EDT 2012
You need to get the Table object and apply the Cell method to the table. If there is only one table, you get the first table from the Tables collection. Then select the cell and get the text from the selection object. There may be a more efficient way to do this. The following snippet is untested, but should be close. Make sure you declare all variables first.
oleGet(objDoc, "Tables", objTables)
clear(objArgBlock)
put(objArgBlock, 1)
oleMethod(objTables, "Item", objArgBlock, objTable)
clear(objArgBlock)
put(objArgBlock, rowNo)
put(objArgBlock, ColNo)
oleMethod(objTable, "Cell", objArgBlock, objCell)
oleMethod(objCell, "Select")
oleGet(objWord, "Selection", objSel) // objWord is Word application object
oleGet(objSel, "Text", sCellText)
Thanks a lot Mr. Bond :)
This works perfectly.
|
|