Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Programming Excel with C++ .Net (MFC)
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Programming Excel with C++ .Net (MFC)
Cheers Fredrik.
I tried the translation program and can make no sense of the code it's producing. However I did make me think about manually translating VBA to C++, since the classes are similiar and there is some help for them in VBA. I have just realise that I can use covOptional for optional variants and have been able use CWorkbooks::Open() method to open my file. Thanks for pointing me in the right direction. Hamish |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Programming Excel with C++ .Net (MFC)
"H." wrote in message ... Cheers Fredrik. I tried the translation program and can make no sense of the code it's producing. However I did make me think about manually translating VBA to C++, since the classes are similiar and there is some help for them in VBA. I have just realise that I can use covOptional for optional variants and have been able use CWorkbooks::Open() method to open my file. Thanks for pointing me in the right direction. Hamish AWell, with late binding, the code isn't easy to understand. The absoultely easiest way to auomate Excel, using compiled code, is to use VB6. You simplu pass Excel.Application to a property and then write code which will be very similar to VBA. If you use C++, you should #imprt excel.exe (Excel 2003) so that you can use early binding. /Fredrik |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Programming Excel with C++ .Net (MFC)
I don't know if this tool could help with this...but if you want check
out www.kdcalc.com...This lets you develop your code in Excel and then KDCalc will convert the excel spreadsheet into either a java or .Net implementation for execution not using Excel. May not help with this but may be useful in the future. There's a free/no registration download of the tool to test with. I've used it a bit and it's saved me a lot of time reprogramming. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Programming Excel with C++ .Net (MFC)
I don't know if this tool could help with this...but if you want check
out www.kdcalc.com...This lets you develop your code in Excel and then KDCalc will convert the excel spreadsheet into either a java or .Net implementation for execution not using Excel. May not help with this but may be useful in the future. There's a free/no registration download of the tool to test with. I've used it a bit and it's saved me a lot of time reprogramming. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
ExCel programming | Charts and Charting in Excel | |||
Excel Programming | Excel Worksheet Functions | |||
Excel/VBA programming | Excel Discussion (Misc queries) | |||
Excel programming | Excel Programming | |||
Excel Programming | Excel Programming |