LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i automatically generate work order numbers from work orde rob h Excel Discussion (Misc queries) 1 July 13th 09 07:59 PM
flash object dont work in my excel work sheet Nitn Excel Discussion (Misc queries) 0 July 4th 09 08:00 AM
HOW TO MAKE A LIST OF WORK SHEET IN WORK BOOK IN EXCEL 2007 goutam Excel Programming 1 February 1st 08 07:40 AM
If I have a work sheet protected and try to run a macro to hide rows or columns it won't work. Correct? Marc Excel Programming 2 July 12th 06 04:10 AM
Programmatic schema mapping, XPath.SetValue question Mike Excel Programming 2 August 23rd 05 11:40 PM


All times are GMT +1. The time now is 07:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"