I'm trying to add data on a new row in Excel 2010, Win 7. Smoehow, the commented line below using XLSetCell (where the row is set to 4 using a litteral) works. but the line above it, that uses the variable NewRow results in OLE error 800A03EC. I tried using %NewRow% also. Same error. stepping through the code, NewRow is being set to 4 as exepcted. What's going on? are variable not supported for specifying the row to edit? is it a defect? We are evaluating, and I'm trying to sell this product to upper management, by doing a demo... Arghh!
Thanks
Eric
Let>totalPDFTime = 5.5
XLOpen>h:\MacroScheduler\PDFLoadTimeResults.xlsx,0,xlBook
XLGetSheetDims>xlBook,Sheet1,nRowCount,nColCount
Let>NewRow = %nRowCount% + 1
XLSetCell>xlBook,Sheet1,NewRow,1,totalPDFTime,scResult
//XLSetCell>xlBook,Sheet1,4,1,totalPDFTime,scResult
XLSave>xlBook,h:\MacroScheduler\PDFLoadTimeResults.xlsx
XLQuit>xlBook
XLSetCell gives error when using a variable for row
Moderators: JRL, Dorian (MJT support)
I don't have Win 7 or Excel 2010 to test with but I do see that you have spaces in your code. Remove the spaces and see if that helps.
With spaces removed it works for me in Xp and excel 2007.
Code: Select all
Let>totalPDFTime=5.5
XLOpen>h:\MacroScheduler\PDFLoadTimeResults.xlsx,0,xlBook
XLGetSheetDims>xlBook,Sheet1,nRowCount,nColCount
Let>NewRow=%nRowCount%+1
XLSetCell>xlBook,Sheet1,NewRow,1,totalPDFTime,scResult
//XLSetCell>xlBook,Sheet1,4,1,totalPDFTime,scResult
XLSave>xlBook,h:\MacroScheduler\PDFLoadTimeResults.xlsx
XLQuit>xlBook
Last edited by JRL on Wed Jan 26, 2011 11:13 pm, edited 1 time in total.
Not referring to the blank lines... its the spaces in the line.
Should be
Or you could use the MS "IgnoreSpaces" variable. At the start of your code add the line.
Code: Select all
Let>NewRow = %nRowCount% + 1
Code: Select all
Let>NewRow=%nRowCount%+1
Code: Select all
Let>IgnoreSpaces=1