Create a control on Visio Document via the Active X control

G

Gary Shell

I am converting some code that was in an Access application that opened an
instance of VISIO and created a document. The new code, in VB.NET
instantiates the VISIO Active X control and uses it to create the same
document. This line:
shpObj = pagObj.InsertObject("Forms.CheckBox.1", &H2000)

attempts to add a checkbox control to the diagram. But it generates the
following error:
"Visio cannot insert this control because VBA is disabled. Controls require
VBA to function properly."

Is it not possible to instantiate a control on a Visio drawing from the
Visio ActiveX control? This worked fine in the old Access/Visio
application.

Gary
 
J

JuneTheSecond

I don't know why, but the case is the same as you, not only in VB .Net but
also in VB6. When I am working on Visio drawing cobtrol, the
application.VBAEnable read-only property stays false. But when I am on
regular Visio, the property is true and can be put the check box on a Visio
drawing in VB .Net
 
G

Gary Shell

Sigh, I was afraid of that. This REALLY stinks. I spent MONTHS converting
code to use the control only to find out part of my app can't be
implemented. I can find ZERO, NADA, ZILCH documentation on the limitations
of the drawing control. Is ANYONE from Microsoft on these forum? Can you
possibly provide some insight into this.

Gary Shell
 
M

Michael Keilhack

Hey,

could it be that you could alter the Registry before starting Visio to
forcefully enable VBA? I check many Registry-Entries before starting
Visio so that my solution is working.

Much luck

Michael
 
G

Gary Shell

Thanks Michael but...

The registry entries indicate VBA is enabled. In fact if you open VISIO the
options clearly show it is enabled. If the application opens VISIO and
manipulates it directly then VBA is enabled. If the app uses the drawing
control VBA appears to be disabled. This is what has me so damn frustrated.
There is little if any documentation on what is and what is NOT supported in
the drawing control. It's very frustrating.

Gary
 
J

JuneTheSecond

I can open a drawing that already has a check box on Drawing Cintrol in VB
..NET.
The check box does not work as a check box, it stays on the drawing only as
a shape, because Drawing Control does not include VBA.
Though I cannot understand why I cannot put check box on the drawing in VB
..NET program.
 
J

JuneTheSecond

Though a check box cannot work as check box, an another idea may be to drop
the check box from the stencil that has a mster made of a check box.
 
G

Gary Shell

Thanks for the idea, but I need to not only add the check box but some code
behind it. In the Access version of the app I added several layers of
lines. Each layer got a checkbox on the diagram and code behind the
checkbox that would turn the layer on or off. Users loved it, since they
didn't have to navigate any menus to display/hide layers.

Gary
 
J

JuneTheSecond

CheckBox could not work with VBA code, because Drawing Contrl does not
include VBA. Another idea would be to make a shape like a check box that
works using event section or action section in the shape sheet.
 
J

JuneTheSecond

My next recommendation would be,,,
There is a shape named checkbox in the stencil named Common Control in
category software.This shape could be dropped on the drawing page in VB .NET.
This shape can be checked or not by pressing right hand button on the mouse
and selecting pop-up menu.
In VB .NET shape changed event could be catched. For example,,,,

Private WithEvents myCheckBox As Microsoft.Office.Interop.Visio.Shape
.....
myCheckBox =
AxDrawingControl1.Window.Application.ActivePage.Drop(doc.Masters(2), 0, 0)
......
Private Sub myCheckBox_CellChanged(ByVal Cell As
Microsoft.Office.Interop.Visio.Cell) Handles myCheckBox.CellChanged
MessageBox.Show(Cell.Name & " changed!")
' or any other code.
End Sub
 
G

Gary Shell

I realize the VBA code will not execute in the Active X control, I didn't
expect it to. The Active X control is just used within the app to create
the drawing. Once created the drawing is immediately saved to disk. Then
the user opens the drawing within VISIO for further viewing or editing.
That's when the VBA code behind the checkboxes would execute.

I got a suggestion in the Partner Forum that this might be a security issue
and the reason I can't instantiate the checkbox control is the security
setting is set to high. I will attempt to lower it and see if that helps,
if so I can then look into assigning a certificate to the app so I can pass
the security tests.

Thanks for your suggestions, I may wind up pursuing them if this tact does
not work out.

Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top