Visio Guy

Visio Discussions => Programming & Code => Topic started by: jfleischman on July 10, 2020, 03:13:42 PM

Title: Locking Background Layer
Post by: jfleischman on July 10, 2020, 03:13:42 PM
Hello,

Wondering if I can get some guidance on how to "lock" a layer that I am using as a background. So far my code is as follows, with my best guess on how to lock it in the last line, which did not work.


'Set the Active Page
VisioPage = VisioDoc.Application.Active Page

'Add New Visio Layer
VisioLayers = VisioPage.Layers
Visio:ayer1 = VisioLayers.Add("Background")

'Import BMP file into background
VisioShape = VisioPage.Import(DestinationFilePath)

'Default Drawing Size MUST = "D" 34in X 22in

'Set Background Image Center Position
VisioShape.CellsU("PinX").FormulaU = "17in"
VisioShape.CellsU("PinY").FormulaU = "11in"

'Set the Background Image size same as the page size
VisioShape.CellsU("Width").FormulaU = "34in"
VisioShape.CellsU("Height").FormulaU = "22in"

'Lock the Background Image
VisioShape.CellsU("LockWidth").Formula = "1"
VisioShape.CellsU("LockHeight").Formula = "1"
VisioShape.CellsU("LockMoveX").Formula = "1"
VisioShape.CellsU("LockMoveY").Formula = "1"
VisioShape.CellsU("LockRotate").Formula = "1"
VisioShape.CellsU("LockSelect").Formula = "1"
VisioShape.CellsU("LockDelete").Formula = "1"
VisioShape.CellsU("LockReplace").Formula = "1"

'Assign Background Image to Background Shape
VisioLayer1.Add(VisioShape, 0)

'Lock the Background Layer
VisioLayer1.CellsU("Lock").FormulaU = "1"


Thanks!
Title: Re: Locking Background Layer
Post by: Surrogate on July 10, 2020, 03:58:37 PM
You want lock your shape via layers management or/and protect  via Lock<some_proprty>?
Title: Re: Locking Background Layer
Post by: jfleischman on July 10, 2020, 04:57:41 PM
I want to lock via layer properties
Title: Re: Locking Background Layer
Post by: jfleischman on July 10, 2020, 05:20:13 PM
Figured it out, anyone with the same problem I solved it like this

VisioLayer1.cellsC(7).FormulaU = "1"