From: GS on
Ben has brought this to us :
> Hi Garry,
>
> That did not work. It looks like Excel VBA syntax not VB6 automation syntax.
>
> Thanks,
>
> Ben
>
> On 5/19/2010 12:34 PM, GS wrote:
>> It happens that Ben formulated :
>>> Hi all,
>>>
>>> I am using VB6 to re-order Excel worksheets. When I open a new
>>> workbook via VB6, it has 3 tabs. I move to the last tab and do:
>>>
>>> oWkbk.Worksheets.Add
>>>
>>> But then the new worksheets "Sheet 4" actutally sits between sheet 2
>>> and sheet 3. I forgot the syntax to actually move it back after sheet
>>> 3. I can't seem to be able to google it either. Please share with me
>>> the proper syntax.
>>>
>>> Thanks,
>>>
>>> Ben
>>
>> Try this:
>>
>> With oWkbk
>> Sheets.Add After:=oWkbk.Sheets.Count
>> End With
>>
>> No need to activate/select any sheet to do this.
>>
>> HTH
>> Garry

Fully qualified refs are always required when automating. I assumed
these were in place already and so did not code for that. The correct
way to do this with proper VB6 fully qualified syntax is:

With gAppXL
.ActiveWorkbook.Sheets.Add
after:=.ActiveWorkbook.Sheets(.ActiveWorkbook.Sheets.Count)
End With

Once again I have made the mistake of assuming. My bad! Sorry about
that!
Garry


From: Karl E. Peterson on
Ben wrote:
> It looks like Excel VBA syntax not VB6 automation syntax.

That's correct. Your question has nothing *whatsoever* to do with VB6
syntax. Your question is about the Excel object model. It really is
imperative that you understand what your own question(s) relate to if
you ever hope to find helpful answer(s).

--
..NET: It's About Trust!
http://vfred.mvps.org