Click here to Skip to main content
15,893,368 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralMenu handle from the floating menu bar Pin
Vaibhav Sanghavi17-Feb-05 1:02
Vaibhav Sanghavi17-Feb-05 1:02 
GeneralRe: Menu handle from the floating menu bar Pin
«_Superman_»17-Feb-05 4:20
professional«_Superman_»17-Feb-05 4:20 
GeneralRe: Menu handle from the floating menu bar Pin
Anonymous20-Feb-05 18:45
Anonymous20-Feb-05 18:45 
GeneralRe: Menu handle from the floating menu bar Pin
Vaibhav Sanghavi20-Feb-05 18:51
Vaibhav Sanghavi20-Feb-05 18:51 
GeneralRe: Menu handle from the floating menu bar Pin
Vaibhav Sanghavi20-Feb-05 18:56
Vaibhav Sanghavi20-Feb-05 18:56 
Generalautocad automation with VC++ Pin
Ajesh.P.S17-Feb-05 0:48
Ajesh.P.S17-Feb-05 0:48 
GeneralRe: autocad automation with VC++ Pin
Aza17-Feb-05 1:31
Aza17-Feb-05 1:31 
GeneralExcel COM from C++ Pin
MJWhiteman217-Feb-05 0:47
MJWhiteman217-Feb-05 0:47 
I'm trying to use some Excel COM from Visual C++, but am having difficulty calling certain functions. For example, take the WorkSheets.Add method. The function declaration is as follows:

LPDISPATCH Add(const VARIANT& Before, const VARIANT& After, const VARIANT& Count, const VARIANT& Type);

By looking in the Excel VBA Help, I can get documentation for this method:

Add Method (Worksheets Collection)

Creates a new worksheet. The new worksheet becomes the active sheet. Returns a Worksheet object.

Syntax

expression.Add(Before, After, Count, Type)

expression Required. An expression that returns a Worksheets object.

Before Optional Variant. An object that specifies the sheet before which the new sheet is added.

After Optional Variant. An object that specifies the sheet after which the new sheet is added.

Count Optional Variant. The number of sheets to be added. The default value is one.

Type Optional Variant. The sheet type. Can be one of the following XlSheetType constants: xlWorksheet, xlExcel4MacroSheet, or xlExcel4IntlMacroSheet. The default value is xlWorksheet.

Remarks

If Before and After are both omitted, the new sheet is inserted before the active sheet.

OK, now for some example code. I can add a new worksheet quite easily using the following code:

// After obtaining a Worksheets object, called ws:<br />
COleVariant VOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);<br />
ws.Add(VOptional, VOptional, VOptional, VOptional


The problem is that this default usage inserts the sheet before all current sheets in my workbook, but I want to insert it after all the other sheets. In Excel VBA, I can do this by simply running:

Worksheets.Add.Move after:=Worksheets(Worksheets.Count)

However, I'm having real trouble finding what the data type of the 'After' argument needs to be in C++ and I can't find any sample code anywhere! I have found hundreds of examples passing numbers or strings, but not objects! Can anyone supply some sample code?

Using the _Worksheet.Move method would also accomplish the same thing, but I have the same problem, so any help would be greatly appreciated!
GeneralRe: Excel COM from C++ Pin
MJWhiteman217-Feb-05 3:45
MJWhiteman217-Feb-05 3:45 
QuestionHow to Find if a machine exists on LAN just by using Machine Name. Pin
RuchirD17-Feb-05 0:16
RuchirD17-Feb-05 0:16 
AnswerRe: How to Find if a machine exists on LAN just by using Machine Name. Pin
ThatsAlok17-Feb-05 2:25
ThatsAlok17-Feb-05 2:25 
Generalresource error Pin
rushing16-Feb-05 23:19
rushing16-Feb-05 23:19 
GeneralRe: resource error Pin
«_Superman_»17-Feb-05 2:28
professional«_Superman_»17-Feb-05 2:28 
GeneralRe: resource error Pin
rushing17-Feb-05 14:25
rushing17-Feb-05 14:25 
GeneralRe: resource error Pin
toxcct17-Feb-05 9:15
toxcct17-Feb-05 9:15 
GeneralRe: resource error Pin
rushing17-Feb-05 14:50
rushing17-Feb-05 14:50 
GeneralRe: resource error Pin
«_Superman_»17-Feb-05 20:26
professional«_Superman_»17-Feb-05 20:26 
GeneralMultilanguage in VS 98. Pin
nguyennp16-Feb-05 23:02
nguyennp16-Feb-05 23:02 
GeneralRe: Multilanguage in VS 98. Pin
Mohammad A Gdeisat16-Feb-05 23:09
Mohammad A Gdeisat16-Feb-05 23:09 
GeneralRe: Multilanguage in VS 98. Pin
Blake Miller17-Feb-05 7:47
Blake Miller17-Feb-05 7:47 
GeneralSending Bmp in peer 2 peer app Pin
Identity Undisclosed16-Feb-05 22:28
Identity Undisclosed16-Feb-05 22:28 
GeneralRe: Sending Bmp in peer 2 peer app Pin
Mohammad A Gdeisat16-Feb-05 23:19
Mohammad A Gdeisat16-Feb-05 23:19 
GeneralRe: Sending Bmp in peer 2 peer app Pin
Identity Undisclosed17-Feb-05 2:37
Identity Undisclosed17-Feb-05 2:37 
GeneralRe: Sending Bmp in peer 2 peer app Pin
Identity Undisclosed17-Feb-05 3:08
Identity Undisclosed17-Feb-05 3:08 
GeneralRe: Sending Bmp in peer 2 peer app Pin
ThatsAlok16-Feb-05 23:32
ThatsAlok16-Feb-05 23:32 

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.