Author Topic: Locking Background Layer  (Read 206 times)

0 Members and 1 Guest are viewing this topic.

jfleischman

  • Newbie
  • *
  • Posts: 5
Locking Background Layer
« on: July 10, 2020, 10:13:42 AM »
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.

Code
'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!

Surrogate

  • Hero Member
  • *****
  • Posts: 983
    • ShapeSheet™ Knowledge Base
Re: Locking Background Layer
« Reply #1 on: July 10, 2020, 10:58:37 AM »
You want lock your shape via layers management or/and protect  via Lock<some_proprty>?

jfleischman

  • Newbie
  • *
  • Posts: 5
Re: Locking Background Layer
« Reply #2 on: July 10, 2020, 11:57:41 AM »
I want to lock via layer properties

jfleischman

  • Newbie
  • *
  • Posts: 5
Re: Locking Background Layer
« Reply #3 on: July 10, 2020, 12:20:13 PM »
Figured it out, anyone with the same problem I solved it like this

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