View previous topic :: View next topic |
Author |
Message |
jicman
Joined: 22 Dec 2004 Posts: 298 Location: Rochester, NY
|
Posted: Thu Mar 19, 2009 12:06 am Post subject: Assigning A Cell Value in Excel |
|
|
Greetings...
I am trying to set a value in a cell, in Excel. I have everything working, except JScript calls like this one:
Code: |
xl.Cells(r,c).Value = "some value";
|
the code I have for d is,
Code: |
scope cv0 = new DispatchObject(xl.call("Cells",r,c));
cv0.set("Value","some value");
|
The program compiles, but when I call it, I am getting,
Quote: |
InvalidCastException: Invalid cast from 'VARIANT ' to 'IDispatch'.
|
I don't know which VARIANT kind it would be cast to. Any help would be greatly appreciated.
thanks,
jose |
|
Back to top |
|
|
jicman
Joined: 22 Dec 2004 Posts: 298 Location: Rochester, NY
|
Posted: Fri Mar 20, 2009 9:24 pm Post subject: |
|
|
So, what I did was that I changed the assignment code for this,
Code: |
xl.WorkSheets(1).Cells(1,1).Value = "some value";
|
for this,
Code: |
scope xlWS = new DispatchObject(xl.get("WorkSheets", 1));
scope wsSel = new DispatchObject(xlWS.get("Cells", 1, 1));
wsSel.set("Value", "some value");
|
so this works.
thanks,
jic |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|