create multiple drawing controls at runtime?

D

damion

Hello,

I have a need to create n instances of the Visio Drawing control at runtime,
in VB6. A simple example use case might be: Select a folder and open all
Visio documents. In my case, it is imperative that all documents be loaded
into memory, rather than simply loading them as I use them. Is it possible
to do this? I've been trying something like the example, but the compiler
doesn't like it, complaining about an improper use of the New keyword. I
have also tried using the CreateObject function, but the compiler throws an
error, "ActiveX component can't create object". Any help would be most
appreciated.

Private Sub CreateNewVisioControl(VisioFile As String)

'create a new Visio Drawing Control and open the VisioFile with it.

Dim NewControl As DrawingControl
'compiler complains about the next line.
Set NewControl = New DrawingControl
NewControl.Src = VisioFile
'do more stuff here...
End Sub
 
R

Roger

Hi Damion

Because Visio drawings take sometime to open I also need to keep several
drawings open. In VB2005 I use:
Dim oVDC As New AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl
Me.Controls.Add(oVDC)

I tried many experiments before arriving at this particular solution. For
example, I initially wanted to use an MDI forms approach but found that
anchor windows don't autohide when the Visio drawing control is contained in
an MDI child form. It might be worth trying the MDI approach in VB6 if it
fits in with your application.

Also when using VB2005, the Office2003 PIA must be installed and the project
must have the correct references to the Visio 11 type library and the drawing
control type library.

I've been developing VB programs for use with Visio since 1994 but have only
just started to use the Visio drawing control. Although I'm still in the
early stages of testing, the Visio drawing control does seem to offer
significant advantages over the other methods of developing Visio solutions
with VB, eg COM add-ins, VSLs and stand-alone VB programs.

Best regards
Roger Billsdon
 
D

damion

Thanks, Roger. Those are some helpful tips, I'll give them a try this
afternoon and see what I can come up with.

Like you, I'm pretty excited about what the drawing control could
potentially offer our applications. We currently use a VSL approach, and due
to the complexity of the apps, we're running into some real problems getting
more control over the process space and windowing issues.

Thanks again!
 

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