Visio Guy

Visio Discussions => General Visio => Topic started by: Lmontenegro on August 10, 2020, 05:51:49 PM

Title: formula disappear when drag and drop from stencil
Post by: Lmontenegro on August 10, 2020, 05:51:49 PM
Hello Everyone

I am adding a drop-down feature to my shapes. I created the formulas on the ShapeSheet to ask the user to assign a Layer as soon as the shape is added to the drawing.

On the stencil the formulas look ok, but when I am grab and drop the shape from the stencil to the drawing, the formula I wrote on the stencil for "Layer Membership" just disappear.

On the screenshot attached...
"ShapeSheet on Stencil.png" show the code on the shape. The "Layer Membership" section shows the formula =User.assign2Shape

BUT,
"ShapeSheet on Drawing.png" when I grab and drop the shape to the drawing, the formula on "Layer Membership" is nos appearing, just brings "0"

How can I fix this issue?

Thanks in advance
Title: Re: formula disappear when drag and drop from stencil
Post by: Paul Herber on August 10, 2020, 06:06:33 PM
Does the layer exist on the page where you are dropping the shape?

Title: Re: formula disappear when drag and drop from stencil
Post by: Surrogate on August 10, 2020, 08:08:00 PM
Try add in section Events in cell EventDrop formula
setf(getref(LayerMember),"user.assign2Values")
Title: Re: formula disappear when drag and drop from stencil
Post by: wapperdude on August 10, 2020, 10:04:45 PM
Perhaps I'm missing something but...
When you are creating the prop entry, you can have ask on drop enabled, plus provide a hint without any time extra steps.  Seems like that what you're trying to accomplish???
Title: Re: formula disappear when drag and drop from stencil
Post by: Lmontenegro on August 10, 2020, 11:26:28 PM
thanks Paul... well, I created manually the 3 layer before dropping the object into the drawing and I have the same issue.
Title: Re: formula disappear when drag and drop from stencil
Post by: Lmontenegro on August 10, 2020, 11:28:17 PM
Thanks for your answer... I am kind of new on Visio and I couldn't find section Events. where and how can I add it?
Title: Re: formula disappear when drag and drop from stencil
Post by: Lmontenegro on August 10, 2020, 11:32:28 PM
wapperdude, I am trying to generate a popup window asking for the layer where the shape needs to be placed. That's all. I haven't been able to get the list of layer, either. But something I found weird is the formula on Layer Membership just disappear when I drop the shape.
Title: Re: formula disappear when drag and drop from stencil
Post by: wapperdude on August 11, 2020, 12:11:57 AM
Exactly!  Do that in dropdown window when you create your Data property or open shapesheet if already defined and make following entries in the Shape Data section:
>> Prompt Cell enter some text providing user with a hint
>> In Ask Cell set to True or 1

See attached example.  <Cntl> + D has same effect as dropping from a stencil.
Title: Re: formula disappear when drag and drop from stencil
Post by: Lmontenegro on August 11, 2020, 02:43:41 AM
thanks wapperdude for the example... this is how I am getting so far... the popup window asking for the layer.

Trying your suggestion, everything works... BUT still losing the formula on the Layer Membership section when I am dropping the shape into the stencil.

the upper part of the screenshot shows the code on the stencil, the lower part of the screenshot is when I drop the shape from the stencil into the drawing.
Title: Re: formula disappear when drag and drop from stencil
Post by: vojo on August 11, 2020, 03:22:19 PM
IMHO, I would consider using prop.data to do 2 things

First, list out layers available...something like
    layer1 = <NA or layer name or layer number>   ///get these from the page shapesheet....parse, etc
    layer2 = <NA or layer name or layer numbername>
    use the  fixed list format to prevent user from overwriting the these props.

Second, an entry to select the layer to use...something like
    Layer_to_place_shape = <layer name or layer number>   

so usage is
    eventondrop = docmd(1312)               // same for eventdblclk
    maybe use setf(getref(<layer cell for this ship>), layer_to_place_shape) to put layer value in the layer cell of shape
    (something like this...never did much with layers so syntax might be wrong).


Title: Re: formula disappear when drag and drop from stencil
Post by: Lmontenegro on August 11, 2020, 06:01:13 PM
thanks Vojo for your help.. I think I have something pretty similar what you are suggesting, I think I am going on the right path... BUT my problem is when I grab and drop the shape into the drawing... the formula on the "Layer Membership" just disappear. Any idea what is generating that weird behavior?
Title: Re: formula disappear when drag and drop from stencil
Post by: wapperdude on August 11, 2020, 06:02:40 PM
Updated file.  Forgot that the LayerMember cell prefers index number.  So, the User cell formula needs to use the Lookup fcn.  Now, the attached should provide what you want...without all of the extra User formulas!

Cheers.
Note, this and the previous example from yesterday do utilize the docmd(1312) double click formula.  Although, that's more for convenience and not really needed for your task.
Title: Re: formula disappear when drag and drop from stencil
Post by: Lmontenegro on August 11, 2020, 06:57:36 PM
 :)Thanks a lot wapperdude, it is working now.
Title: Re: formula disappear when drag and drop from stencil
Post by: Lmontenegro on November 01, 2020, 04:36:59 AM
Hello, I am using the code to assign layers when I drop a shape. It is working, however, I would like to load the dropdown menu with the existing layer names on the page. I have been trying with the following formula, but it is not working when I drag a shape from the stencil.

User-defined Cells:
User.LayerData = SETF(GetRef(LayerMember),LOOKUP(Prop.LayerData,User.LayerList))
User.LayerList =  ThePage!Layers.Name&";"&ThePage!Layers.Name[2]&";"&ThePage!Layers.Name[3]&";"&ThePage!Layers.Name[4]

Shape Data:
Prop.colorShape
Format = User.LayerList
(Value)  =INDEX(2,Prop.LayerData.Format)






Title: Re: formula disappear when drag and drop from stencil
Post by: Surrogate on November 03, 2020, 08:36:27 AM
Which visio version do you use?
I find this topic Visio shapesheet get Layer index from name (https://stackoverflow.com/questions/40637366/visio-shapesheet-get-layer-index-from-name/45458430#45458430)
My suggest from that topic dont work with Visio 2013 and newest versions...