Create a connector in a new layer?

M

Mac

How do I (programatically) create a connector in a new layer? When you create
a connect object it goes to the Connector layer by default ( I suppose). I
want to change this behaviour and make it to appear in a new layer.

I'm thinking of a scenario - create a connector (it goes to the Connector
layer), create a new layer, move the connector form the Connector layer to
this new layer. Is there another way?

Also - what is the correct code for creating new layers? What parameters do
I have to set for it to be accepted by the rest of the system?
 
A

Al Edlund

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top