Class CustomView (Excel VBA)
The class CustomView represents a custom workbook view.
To use a CustomView class variable it first needs to be instantiated, for example
Dim cvw as CustomView Set cvw = ActiveWorkbook.CustomViews(ViewName:=1)
Here is an example of processing the CustomView items in a collection.
With Worksheets(1) .Cells(1,1).Value = "Name" .Cells(1,2).Value = "Print Settings" .Cells(1,3).Value = "RowColSettings" rw = 0 For Each v In ActiveWorkbook.CustomViews rw = rw + 1 .Cells(rw, 1).Value = v.Name .Cells(rw, 2).Value = v.PrintSettings .Cells(rw, 3).Value = v.RowColSettings Next End With
Deletes the object.
Returns a String value that represents the name of the object.
Dim strName As String strName = ActiveWorkbook.CustomViews(1).Name
True if print settings are included in the custom view.
Dim booPrintSettings As Boolean booPrintSettings = ActiveWorkbook.CustomViews(1).PrintSettings
True if the custom view includes settings for hidden rows and columns (including filter information).
Dim booRowColSettings As Boolean booRowColSettings = ActiveWorkbook.CustomViews(1).RowColSettings
Displays the object.
Creates a new custom view.
Dim strViewName As String: strViewName = Dim cvw As CustomView Set cvw = ActiveWorkbook.CustomViews.Add(ViewName:=strViewName)
The following arguments are optional
Returns a Long value that represents the number of objects in the collection.
Dim lngCount As Long lngCount = ActiveWorkbook.CustomViews.Count
Returns a single object from a collection.
ViewName: The name or index number for the object.
Dim cvw As CustomView Set cvw = ActiveWorkbook.CustomViews(ViewName:="Current Inventory")