OLECallMethod - Adding Worksheets (OpenInsight 32-Bit)
At 18 MAR 2011 12:25:09PM ctinnell wrote:
I am using OLECallMethod to 'Add' worksheets without difficulty. However, the default behavior for this method seems to place the Added worksheet as the first item.
There are additional arguments for the Add method (Before, After) to allow placing the Added worksheet in some other position, but 'Before' and 'After' appear to require an object (an variable) as the argument. An ENG error occurs when an idispatch variable is placed in the OLECallMethod call.
Placing an item number or a worksheet name as an argument does not generate an error, but the new worksheet is not Added either.
Does anyone know how to specify the placement of an Added worksheet?
Thanks,
Skip Tinnell
CDM, Inc.
At 31 MAR 2011 03:24AM Colin Rule wrote:
I have tried this and I can only get it to Add before the current worksheet.
The VB code on MSDN states
returnValue=sheets1.Add(Before, After, Count, Type)
I have tried assigning oPrev from oSheet so the previous object is used:
oSheet=OLECallMethod(oSheets,"Add","",oPrev)
As you say it does not create a new sheet, so could be an error in my syntax, or just me not understanding the parameters being passed.
If anyone else has a solution to this, I too would be grateful.
Colin