VBA Pete
VBA Pete

Reputation: 2666

Make Visio layer visible through Excel macro

I am trying to make a layer in Visio visible through an Excel Macro, that I wrote. However, I always an invalid parameter error.

This is my code:

Sub visio_change_shape(index_value As Variant)

Dim AppVisio As Object
Dim VisioSystems As Object

Set AppVisio = GetObject(, "Visio.Application")

AppVisio.Pages(1).Layers.Item(index_value).CellsC(visLayerVisible).FormulaU = "1"

End Sub

However, in visio the same line works:

Private Sub Select_layers()
Dim vsoPage As Visio.Page
Dim vsoShape As Visio.Shape
Dim vsoLayers As Visio.Layers
Dim vsoLayer As Visio.Layer

Set vsoPage = ActivePage
Set vsoLayers = vsoPage.Layers

vsoLayer.CellsC(visLayerVisible).FormulaU = "1"

Next

End Sub

Thanks for any leads!

Upvotes: 0

Views: 666

Answers (1)

Paul Herber
Paul Herber

Reputation: 1200

All you actually need is:

ActiveDocument.Pages(1).Layers.Item(index_value).CellsC(visLayerVisible).Formula = "1"

index_value should be a short int.

Upvotes: 1

Related Questions