Prev: Programming Strategy for Taking Meeting Minutes
Next: Reminder - Microsoft Responds to the Evolution of Community
From: Ben on 19 May 2010 12:26 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
From: GS on 19 May 2010 12:34 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
From: GS on 19 May 2010 12:39 GS pretended : > 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 Oops! The code should read... With oWkbk .Sheets.Add After:=.Sheets.Count End With Sorry about that! Garry
From: Ben on 19 May 2010 13:08 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 > >
From: Ben on 19 May 2010 14:05
Garry, It gave me a Run-time error '1001': Method 'Add' of object 'Sheets' failed. But I just found something on the web, http://www.vbforums.com/showthread.php?t=366481 oWkbk.Worksheets.Add After:=oWkbk.Worksheets(oWkbk.Worksheets.Count) This worked. Thanks so much for your time and your help. Ben On 5/19/2010 12:39 PM, GS wrote: > GS pretended : >> 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 > > Oops! The code should read... > > With oWkbk > .Sheets.Add After:=.Sheets.Count > End With > > Sorry about that! > Garry > > |