WksCellFormat Object

The WksCellFormat object contains the properties of one or more worksheet cells such as the numeric format and the alignment.

The following table provides the properties of the WksCellFormat object:

Property

Description

Alignment

Returns/sets the horizontal alignment. Returns null if not all the cells in a Range have the same horizontal alignment.

Application

Returns the Application object. It is a read-only property.

BackColor

Returns/sets the background color. Returns null if not all the cells in a Range have the same background color.

DateFmtType

Returns/sets the date format type. Returns null if not all the cells in a range have the same date format type.

Digits

Returns/sets the number of decimal digits. Returns null if not all the cells in a Range have the same number of decimal digits.

NumericType

Returns/sets the numeric format type. Returns null if not all the cells in a Range have the same numeric format type.

Parent

Returns the parent Range of this CellFormat object. It is a read-only property.

Thousands

Returns/sets whether numbers are formatted with thousands separator characters. Returns null if not all the cells in a Range have the same thousands separator formatting.

TimeFmtType

Returns/sets the time format type. Returns null if not all the cells in a range have the same time format type.

Following table provides the methods of the WksCellFormat object:

Method

Description

SetDateTimeFmtType

Sets both date and time format types.

Example

The following script demonstrates how the WksCellFormat object is used in reference to the WksRange object.

Sub Main

 

'Declares SurferApp as an object

Dim SurferApp As Object

 

'Creates an instance of the Surfer Application object and assigns it

'to the variable named "SurferApp"

Set SurferApp = CreateObject("Surfer.Application")

 

'Makes Surfer visible

SurferApp.Visible = True

 

'Declares Wks as an object

Dim Wks As Object

 

'Opens a worksheet document in Surfer and assigns it to the variable

'named "Wks

Set Wks = SurferApp.Documents.Open(FileName:=SurferApp.Path+"\Samples\demogrid.dat")

 

'Declares WksRange as an object

Dim WksRange As Object

 

'Assigns columns A, B, and C to the variable named "WksRange"

Set WksRange = Wks.Columns(Col1:=1, Col2:=3)

 

'Declares WksCellFormat as an object

Dim WksCellFormat As Object

 

'Assigns the cell format of the range to the variable named

'"WksCellFormat"

Set WksCellFormat = WksRange.Format

 

End Sub