View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Fredrik Wahlgren Fredrik Wahlgren is offline
external usenet poster
 
Posts: 339
Default Programming Excel with C++ .Net (MFC)


"H." wrote in message
...
Hi
I have a couple of queries about adding excel functionality to my program.
I want to open excel using a excel template or excel file that I have
already created.
I've tried using CWorkbooks::Open() method, but I new to this and am
struggling with all the VARIANT parameters.
Does anyone know how to do this or able to point me in the right

direction?
Secondly, I want to be able to select a cell at run time to place some

data.
I have me able to pick a row in column A using:
int Row;
CString CellStr;
.
.
.
CellStr.Format("A%d",row);
oRange = oSheet.get_Range(COleVariant(CellStr),covOptional) ;

Is there a better way to pick just one cell, instead of using the Range
method?
Also, is there an easy way to pick the column at runtime?

Thanks
H.



First of all, you should create a VBA macro that does something similar to
what you want to do from your C++ program. Once you have something that
works, it should be easier to convert to C++, especailly if you use early
binding. Here's a tool that may be useful, it converts VBA code to C++ using
late binding.

http://support.microsoft.com/kb/216388

/Fredrik