FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Assigning A Cell Value in Excel

 
Post new topic   Reply to topic     Forum Index -> Juno
View previous topic :: View next topic  
Author Message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Thu Mar 19, 2009 12:06 am    Post subject: Assigning A Cell Value in Excel Reply with quote

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
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Fri Mar 20, 2009 9:24 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Juno All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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