Show code in...     

  

 

Object Model ExcelApplication Worksheets Worksheet Cells Cell Range
Charts Chart SeriesCollection Series 3DProperties Axis ChartFrame Line Area
PivotField PivotFields PivotTable PivotTables
Style Characters Font Pictures Picture DocumentProperties PageSetup


The Worksheets Object (SAWorksheets)

Worksheets Methods and Properties

Worksheets Methods and Properties
Add

Adds a worksheet to your Excel application. To add second and third worksheets to an existing Excel application, use,

Signature:


[VBScript]
Function Add([SheetName As String]) As Integer

Example:



[VBScript]

xlw.Worksheets.Add
dim Worksheet2 
set Worksheet2 = xlw.Worksheets(2)
		
xlw.Worksheets.Add
dim Worksheet3 
set Worksheet3 = xlw.Worksheets(3)

Top

Count

Counts the number of worksheets in your Excel application (workbook).

Signature:


[VBScript]
Property Count As Integer (read-only)

Example:



[VBScript]

Dim SheetCount, XlwApp
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")

'--- Get the number of sheets in the workbook
SheetCount = XlwApp.Worksheets.Count

Top

Item

Represents a single worksheet in a Worksheet collection. Item is the default property of Worksheets, so Worksheets(1)  is equivalent to Worksheets.Item(1) . You can reference a Worksheets item either by number or by name.

Signature:


[VBScript]
In VBScript, this is the default property for the SAWorksheets object.

Property Item As SAWorksheet (read-only)

Example:



[VBScript]

Dim XlwApp, WrkSht
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")

'--- Get the first worksheet in the workbook
Set WrkSht = XlwApp.Worksheets(1)


Top

Remove

Removes a worksheet from the specified Excel workbook. Remove takes the worksheet's name or index number as a parameter.

Signature:


[VBScript]
Sub Remove(Sheet As Variant)

Example:



[VBScript]

Set oXLW = Server.CreateObject("SoftArtisans.ExcelWriter")
...
oXLW.Worksheets.Remove(2)

Top



Object Model ExcelApplication Worksheets Worksheet Cells Cell Range
Charts Chart SeriesCollection Series 3DProperties Axis ChartFrame Line Area
PivotField PivotFields PivotTable PivotTables
Style Characters Font Pictures Picture DocumentProperties PageSetup


Copyright © 2005, SoftArtisans, Inc.