Stencil drag and drop in 2003

Started by mike9682000, April 14, 2010, 08:34:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mike9682000

Hello all,

I am brand new to VB programming. I have visio 2003 standard and would like to:
Display a VB form when I drag and drop a stencil (each stencil with its form form) into any drawing
Associate a module with each stencil and create stencil properties.

Any ideas?

Thx,
Mike

Nikolay

#1
Quote from: mike9682000 on April 14, 2010, 08:34:49 PM
I am brand new to VB programming. I have visio 2003 standard and would like to:
Display a VB form when I drag and drop a stencil (each stencil with its form form) into any drawing
Associate a module with each stencil and create stencil properties.

Hi Mike,

Are you sure you're not confusing "Master" with "Stencil"?
"MASTER" is a figure like rectangle, circle, arrow, etc you drop form a "STENCIL" window to the drawing surface.

Please take a look here:
http://blogs.msdn.com/mailant/archive/2005/03/24/401566.aspx

If you want to add some data fields to a master, you can just do that and you don't really need any VB programming to accomplish this task. Use "Define shape data" Visio command to define data fields you want to associate with shapes created out of the master. To prompt user with Visio-supplied form, you can set "Prompt on drop" checkbox for the data field.
TFM is your best friend here :D

Hope it helps, Nikolay.

mike9682000

Hello Nikolay,

Thanks for your answer.

Indeed, I was confusing "Stencil" with "Master".

I found the shape custom properties. Thank You.

I am still looking for the EVENT of dragging and dropping of a master into any drawing. I dream of a VB macro like this:

Public Sub Master1_Drag&Drop ()
frmInputDataMaster1.show
End Sub

I figured I can design this as a VB module which will turn the mouse cursor into the desired shape, drop it on left click, then ask for info. I am hoping there is a simpler way.

Again, I am talking Visio 2003.

Yacine

Hi Mike,
this functionality can be implemented very easily.
You need to call your macro from your shapesheet, in the cell "Event Drop" (near the bottom) by the function CALLTHIS.
I always forget where I need to write the macro - It is in the document part, not a module.
Yacine

mike9682000

Quote from: Yacine on April 15, 2010, 08:21:19 PM
I always forget where I need to write the macro - It is in the document part, not a module.

This is my problem: I need to implement this macro in the stencil file only so it works with any document.

Jumpy

#5
Open a stencil in edit mode. Hit Alt+F11 to get to the VBA editor. You will see a VBA project of zour drawing and one of your stencil.
Place your forms or VBA code you need in a VBA modul of the stencil's project.

The Code needs at least the following:

Public Sub mycode(shp As Visio.Shape)
'do sth.
End Sub

The reason is, that we will call this Sub from the shapesheet with Callthis, which will pass along a reference to the calling shape.

In the shapesheet in the cell EventDrop place a formular loke this:
CALLTHIS("mycode","project",)
"project" should be the name of the stencil, further arguments can be added, too, behind the second ","