![]() |
SetItem and SetValue Does Not Work
I use Visual C++ MFC 4.2.
I am developing an Excel file automation process. I need to update the value of the cells. I have succeeded in getting the old value of that cell but when I tried to update with the new value, it did not work. What cause it? I have tried both SetItem and SetValue: Worksheets sheets = book.GetSheets(); _Worksheet sheet = sheets.GetItem( COleVariant( ( short )1 ) ); LPDISPATCH lpDisp = sheet.GetRange( COleVariant( "A1" ), COleVariant( "A1" ) ); ExcelRange range; range.AttachDispatch( lpDisp ); VARIANT varRet = range.GetText(); TRACE( CString( varRet.bstrVal ) + "\n" ); lpDisp = sheet.GetRange( COleVariant( "A1" ), COleVariant( "A1" ) ); range.AttachDispatch( lpDisp ); range.SetValue( COleVariant( "XYZ" ) ); range.SetItem( COleVariant( ( short )1 ), COleVariant( "A" ), COleVariant( "ABC" ) ); range.ReleaseDispatch(); How to solve this? Thank you very much. |
All times are GMT +1. The time now is 11:40 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com