This is from the visio sdk available on msdn
al
'*********************************************************************
'*********************************************************************
'
' Layer to Page
'
'*********************************************************************
'*********************************************************************
Public Sub AddLayerToPage _
(vsoPage As Visio.Page, _
strName As String, _
Optional strNameU As String, _
Optional blnPrint As Boolean = True, _
Optional blnSnap As Boolean = True, _
Optional blnGlue As Boolean = True, _
Optional blnLock As Boolean = True, _
Optional strColorFormulaU As String)
' AddLayer
'
' Abstract - This procedure adds a layer using the Add
' method on the Layers object. Optionally it sets the
' universal name of the layer. It also sets some of the
' properties of a layer that can be set through the Layer
' Properties dialog in the UI.
'
' Parameters
' vsoPage Page object under consideration
'
' strName Name of the layer (This is the local
' name which appears in the UI.)
'
' strNameU Universal name of the layer.
'
' blnPrint To print or not
'
' blnSnap To snap or not
'
' blnGlue To glue or not
'
' blnLock To lock or not
'
' strColorFormulaU The Color Formula for the layer in
' universal syntax.
'
Dim vsoLayers As Visio.Layers
Dim vsoLayer As Visio.Layer
Dim vsoCell As Visio.Cell
On Error GoTo AddLayer_Err
' Get the Layers collection and add a layer named
' strName.
Set vsoLayers = vsoPage.Layers
Set vsoLayer = vsoLayers.Add(strName)
' If the the optional parameter strNameU is not
' blank, then set the universal name for this layer
' to strNameU.
If (Len(strNameU) > 0) Then
vsoLayer.NameU = strNameU
End If
' Set the value of the layer's Print cell.
Set vsoCell = vsoLayer.CellsC(visLayerPrint)
vsoCell.ResultIU = blnPrint
' Set the value of the layer's Snap cell.
Set vsoCell = vsoLayer.CellsC(visLayerSnap)
vsoCell.ResultIU = blnSnap
' Set the value of the layer's Glue cell.
Set vsoCell = vsoLayer.CellsC(visLayerGlue)
vsoCell.ResultIU = blnGlue
' Set the value of the layer's Lock cell.
Set vsoCell = vsoLayer.CellsC(visLayerLock)
vsoCell.ResultIU = blnLock
' Set the layer's color if the parameter
' strColorFormulaU is not blank.
If (Len(strColorFormulaU)) > 0 Then
' Get the cell and set its universal formula.
Set vsoCell = vsoLayer.CellsC(visLayerColor)
vsoCell.FormulaU = strColorFormulaU
End If
Exit Sub
AddLayer_Err:
MsgBox "AddLayerToPage " & strNameU & " " & Err.Description
End Sub