View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default Move of Sheet screws up Stored Sheets

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

Sub MakeAnotherAndMoveIt()
Dim objFirst As Excel.Worksheet
Dim objSecond As Excel.Worksheet
Dim objWB As Excel.Workbook

'Create new workbook
Set objWB = Workbooks.Add

'Get reference to the first sheet.
Set objFirst = objWB.Worksheets(1)

'Add new sheet after the first sheet and secure a reference to it..
Set objSecond = objWB.Worksheets.Add(after:=objFirst, Count:=1)

'Move the new sheet to the first position again.
objSecond.Move befo=objFirst
End Sub
'-------------------


"Grasshopper"

wrote in message
When I add a workbook I get only 1 sheet, not sure why it's not 3, but
nonetheless there's the 1. I use the Item( 1 ) method to get the pointer of
the worksheet. I store it for future use. If I add a worksheet, I store the
pointer as well. All is fine. Item, Index, Name both work fine and I can
select between the two without problems. If I do a Move of a sheet then a
call to get the Name, Item, Index properties fails. Any ideas? Thanks.
-G-