J
Jason V
This is a continuation of help I recieved on another question which I
received help, but I have now incurred a new problem. I am dropping shapes
onto a page based on a shapename I get from excel. After dropping the shape I
use code to access the shapes custom prop to place a value in it. I do this
in a For loop until I am out of shape names. My index is i. I recorded a
macro to get the code to the code to access the shape and then used code that
I received from help. When i = 1 everything works vsoshape gets set to the
shape I just dropped. The next time through the code I want vsoshape set to
the next shape I dropped but vsoshape , but it is set to "Sheet.2", then I
get an error. When i =3 then vsoShape gets set to "Sheet.3" and so on. I
don't know why this works for i=1 or what UndoScopeID1 does. Can anyone help.
For i = 1 To Shapecount
Set xlwb = .ActiveWorkbook
Set oSheet = .ActiveSheet
Shapename = Left(oSheet.Cells( i, 1), 5)
ShapeText = oSheet.Cells( i, 4)
Set mstStencil = stencil.Masters(Shapename)
ThisDocument.Pages("Oneline").Drop mstStencil, ShapePinX, ShapePinY
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Custom Properties")
Dim vsoShape As Visio.Shape
Dim vsoCell As Visio.Cell
Set vsoShape = Application.ActiveWindow.Page.Shapes.ItemFromID(i)
Set vsoCell = vsoShape.Cells("Prop.LABEL.value")
vsoCell.FormulaU = ShapeText
Application.EndUndoScope UndoScopeID1, True
Set vsoCell = Nothing
Set vsoShape = Nothing
Next i
received help, but I have now incurred a new problem. I am dropping shapes
onto a page based on a shapename I get from excel. After dropping the shape I
use code to access the shapes custom prop to place a value in it. I do this
in a For loop until I am out of shape names. My index is i. I recorded a
macro to get the code to the code to access the shape and then used code that
I received from help. When i = 1 everything works vsoshape gets set to the
shape I just dropped. The next time through the code I want vsoshape set to
the next shape I dropped but vsoshape , but it is set to "Sheet.2", then I
get an error. When i =3 then vsoShape gets set to "Sheet.3" and so on. I
don't know why this works for i=1 or what UndoScopeID1 does. Can anyone help.
For i = 1 To Shapecount
Set xlwb = .ActiveWorkbook
Set oSheet = .ActiveSheet
Shapename = Left(oSheet.Cells( i, 1), 5)
ShapeText = oSheet.Cells( i, 4)
Set mstStencil = stencil.Masters(Shapename)
ThisDocument.Pages("Oneline").Drop mstStencil, ShapePinX, ShapePinY
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Custom Properties")
Dim vsoShape As Visio.Shape
Dim vsoCell As Visio.Cell
Set vsoShape = Application.ActiveWindow.Page.Shapes.ItemFromID(i)
Set vsoCell = vsoShape.Cells("Prop.LABEL.value")
vsoCell.FormulaU = ShapeText
Application.EndUndoScope UndoScopeID1, True
Set vsoCell = Nothing
Set vsoShape = Nothing
Next i