During development everything was fine, early binding worked a treat, but now I've moved to late binding for production and I'm having issues with Visio Enums. As follows:
Set AppVisio = CreateObject("visio.application")
Set vsoSelection = AppVisio.ActiveWindow.Selection
Call vsoSelection.GetIDs(lngShapeIDs)
With .Shapes.ItemFromID(lngShapeIDs(0))
.CellsSRC(visSectionObject, visRowXFormOut, visXFormPinX).FormulaU = sngShapeHCenter
.CellsSRC(visSectionObject, visRowXFormOut, visXFormPinY).FormulaU = sngShapeVCenter
.CellsSRC(visSectionObject, visRowXFormOut, visXFormWidth).FormulaU = sngShapeWidth
.CellsSRC(visSectionObject, visRowXFormOut, visXFormHeight).FormulaU = sngShapeHeight
End With
In early binding
visSectionObject, visRowXFormOut, visXFormPinX etc.
all resolve, but I can't get them to resolve in Late Binding.
I've tried adding AppVisio. to prefix the parameters to no avail, can anyone help and tell me the correct way of referencing the Enums?
I've tried using the Visio VBA recorder to see what it gives, but it is not as verbose as I'd hoped (yes, I know, it is so verbose but not on this occasion).
This needs to work for Visio 2010 and 2013 etc.
That's one of the trade-offs of late binding, or more precisely of not setting an explicit reference in Tools>References. The pre-defined enums are then no longer available.
You'll have to replace the enums with their numerical value (see e.g. this list).
For example, the numerical value of
visRowXFormOut
is1
, which you can check for yourself in the Immediate window:So you can either replace all instances of
visRowXFormOut
with1
s, or declarevisRowXFormOut
as a constant:and keep the rest of your code as is.