Hide or Unload Method?

Started by nilani, September 18, 2011, 04:05:25 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nilani

Hi,

I have created VBA user forms to change some parameters of shapes in a Visio 2010 template. The form has a "OK" button and after providing the necessary data user clicks "OK" button.
I have provided the hide method in the "OK" button click event. So when I put another shape(same type of shape) on the drawing and double clicks to open the user form it has the previous values. This is because of the Hide method. But if I use unload method the all data provided in the shape is gone if I double clicks the same shape again. How to avoid this problem? :( I have tried a lot...

Paul Herber

It's not a problem, it's how they work.
If you use the Unload method then you might want to save the form values first, then you can reload them from whatever source when you reload the form. If you just hide the form then unhiding it will just bring back the same values. You'll need to fill in any new form values.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

nilani

Hi Paul,

Thank you for the answer. This is my problem. I have created a stencil with some shapes and when a user double clicks a shape a user-form appears. If there are more than one shapes in the same shape type on the active page same values are appears in the forms.

Ex. If I put name of the first shape as "A1" in the user form,when I double click the next shape to type the name user-form contains the same name as "A1"?

And the other problem is I get these values to the shape Sheet of the shape via the user-form. And if I open the drawing again after closing it and double clicks the shape, user-form does not contain the values that I have provided?
Please help me?

Jumpy

The procedure you use, when you doubleclick on the shape has to open the form and fill it with the right values.
In the shapesheet, dblclick-cell you start/call the procedure with Callthis("MyFormStarter").

In the VBA-Modul you declare it with variable to reference a shape:

Sub MyFormStarter(shp as Visio.Shape)
  'Say you want to change the width of the shape in your form,
  'to get the current values:
  MyForm.textbox_Name.Text = shp.Name
  MyForm.textbox_Width.Text = shp.Cells("Width").ResultStr(0)
  MyForm.Show '/Load / Initialize, don't now the right syntax
End Sub

nilani

Hi Jumpy,
Thanks for the code. I have used RUNADDON in the event section of the shapesheet. The following is the code that I use to get the values from the user form.
Application.ActiveWindow.Shape.CellsSRC(visSectionProp, 0, visCustPropsValue).FormulaU = cmbName.Text

After receiving the values frmCreate.Hide and hidethe form. So when I save the drawing,close it and open again the values are not loaded in to the user form? :(