Click here to Skip to main content
15,899,475 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CSocket Pin
sunit526-Aug-05 0:08
sunit526-Aug-05 0:08 
AnswerRe: CSocket Pin
MailtoGops26-Aug-05 3:05
MailtoGops26-Aug-05 3:05 
GeneralRe: CSocket Pin
sunit526-Aug-05 3:41
sunit526-Aug-05 3:41 
GeneralRe: CSocket Pin
MailtoGops26-Aug-05 3:52
MailtoGops26-Aug-05 3:52 
GeneralRe: CSocket Pin
sunit526-Aug-05 4:17
sunit526-Aug-05 4:17 
AnswerRe: CSocket Pin
Moak (not logged in)27-Aug-05 22:27
sussMoak (not logged in)27-Aug-05 22:27 
QuestionExcel Automation Pin
Identity Undisclosed25-Aug-05 21:52
Identity Undisclosed25-Aug-05 21:52 
AnswerRe: Excel Automation Pin
Steve S25-Aug-05 23:44
Steve S25-Aug-05 23:44 
This is relatively easy, once you're familiar with the Excel object model. Of course, MS give most information for VB developers, but it isn't too hard.

Firstly, from the application object, get the Workbooks collection. From there, you can access already open workbooks, create new ones in the collection (but not necessarily save them to disk) and open existing files.

The method from the workbooks collection you want is 'Open'. This lets you open an existing file. From there, again, you can get the workbook itself (Workbooks Item) and from there the worksheet, and work with ranges etc. Then you can call the Workbook (the item not the collection) save method to write your changes.

Check out by searching for XLCLIENT in MSDN, and "Excel automation VC++" too. There is information in there, you just have to find it.

The hardest part is that in VB examples you see stuff like

set wb = application.workbooks("test1.xls")

and you have to figure out how to convert that to C++.

There was a useful tool which takes VB code in and spits out C++ stuff specifically for this purpose on the MS site, but I can never find it. It wasn't perfect but helped a lot.

Essentially, for any method that returns an object (like workbooks Item), you will need a corresponding wrapper object to hold the returned object, and then call it's methods, so it gets a bit long-winded.

One other caveat is that for a lot of methods, there will be arguments you don't want to specify, but cannot leave out, so you will need to construct a VARIANT for this purpose.

COleVariant v;
v.vt = VT_ERROR;
v.scode = DISP_E_PARAMNOTFOUND;

You can then pass v for optional args you don't want.

I tend to use #import on the type libraries, which does a similar thing to the MFC generation, but I find simpler to use.

Hope this helps.

Steve S
Developer for hire!
AnswerRe: Excel Automation Pin
Rage26-Aug-05 0:33
professionalRage26-Aug-05 0:33 
QuestionHow to Hide WindowName and Rectangle From Taskbar Pin
Amarelia25-Aug-05 20:55
Amarelia25-Aug-05 20:55 
AnswerRe: How to Hide WindowName and Rectangle From Taskbar Pin
dharani25-Aug-05 22:26
dharani25-Aug-05 22:26 
GeneralRe: How to Hide WindowName and Rectangle From Taskbar Pin
Amarelia26-Aug-05 2:57
Amarelia26-Aug-05 2:57 
QuestionCan you tell me how can I control speeds of IIS. Pin
10244225-Aug-05 20:09
10244225-Aug-05 20:09 
QuestionHiding characters in text file Pin
m_shezy25-Aug-05 19:35
m_shezy25-Aug-05 19:35 
QuestionAbout CMonthCalCtrl : Plz Help. Pin
parims25-Aug-05 18:48
parims25-Aug-05 18:48 
QuestionHelp Really need!! Pin
cue_ball25-Aug-05 17:14
cue_ball25-Aug-05 17:14 
AnswerRe: Help Really need!! Pin
dharani25-Aug-05 17:33
dharani25-Aug-05 17:33 
AnswerRe: Help Really need!! Pin
Weiye Chen25-Aug-05 17:58
Weiye Chen25-Aug-05 17:58 
GeneralRe: Help Really need!! Pin
cue_ball25-Aug-05 18:04
cue_ball25-Aug-05 18:04 
GeneralRe: Help Really need!! Pin
Weiye Chen25-Aug-05 18:15
Weiye Chen25-Aug-05 18:15 
GeneralRe: Help Really need!! Pin
cue_ball25-Aug-05 18:36
cue_ball25-Aug-05 18:36 
GeneralRe: Help Really need!! Pin
Weiye Chen25-Aug-05 19:12
Weiye Chen25-Aug-05 19:12 
GeneralRe: Help Really need!! Pin
cue_ball25-Aug-05 19:28
cue_ball25-Aug-05 19:28 
GeneralRe: Help Really need!! Pin
Weiye Chen25-Aug-05 20:10
Weiye Chen25-Aug-05 20:10 
GeneralRe: Help Really need!! Pin
cue_ball25-Aug-05 22:45
cue_ball25-Aug-05 22:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.