issue with addin and stencils

Started by perry59, July 26, 2021, 03:24:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

perry59

I have an addin that that I built using Nikolay's awesome template. When it installs it also "publishes" stencils and templates to folders in the addin's directory.
they show up there just fine, but visio is still looking at old directories. I thought "publishing" would set visio's file locations to the addins location.
Is that not the case? How do I get the addin to change visio's file locations to the correct place?
Thanks
what, me worry?

JohnGoldsmith

Hi,
These are two independent mechanisms:You should use one or the other but not both (for the same solution).
If your stencils and templates are coming from your install directory and being surfaced in the UI via Publishing, then you can delete those paths from the respective File Locations fields.  Does that work for you?
Using the Publishing route is usually a better option if you're using an installer as it allows you to create language specific versions of your files (only surfacing the correct one for the current language), to separate the physical location of the file from the path that the user sees in the UI.  It also allows for an easier uninstall/update experience as the content files get uninstalled along with the addin.
Does that answer your question?
Best regards
John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

perry59

I'm not even sure I understand the answer!
I thought surfacing was something you did with an old bowling ball?
When my installer (Wix based) runs it creates a directory for my application. In that directory is the VSTO file, config file, etc. it also create two subfolders for stencils and templates and does copy the applicable files there.
when visio starts it does not show these templates and stencils in the UI and the paths are not appended to existing paths in options->file locations.
I thought that in the past that the installation did do this, the only thing I remember changing is putting the stencils/templates in their own subfolders rather than dumping them into the applications directory.
I don't think my installer does anything with "path discovery".
Perry
what, me worry?

Nikolay

#3
Quotewhen visio starts it does not show these templates and stencils in the UI

There is no need to modify options => file locations. The installer does not touch them (and it is not supposed to, these are considered user settings)
The stencils are registered using component publishing (adding registry entries).
Even if you clear all the fields in the "path" dialog, the installed stencils / templates should still stay available.

If you are not seeing them, that could be another Visio feature - you have "metric" stencils and "imperial" template (or vice versa).
Try naming your stencils the way they end with "<yourname>_m.vssx" or "<yourname>_u.vssx" (add suffix _m or _u depending on the type you want your stencil to show up).

I believe this is a feature of Visio 2013 and above, but may be mistaking.
Probably a warning could be added for the case stencils do not end with _u or _m and Visio 2013 and above is targeted.

Also, you need to specify menu path where you want your stencils to show up, i.e. to surface.
I mean, in the installer, in the <visio:PublishStencil ...> element. If you don't have <visio:PublishStencil> then please add it, this is doing the registration.
Means, the installer does not automatically register all stencils, only those which you register with the construct above. Could look something like this:

<File Name="StencilA_m.vssx">
  <visio:PublishStencil MenuPath="My Solution\Stencil A" />
</File>

If you create a blank project and add stencils directly in the project wizard, it adds this code automatically.

perry59

my typical publish statement in "product.wxs" looks like this:

<Component>
        <File Name="Components.vss">
          <visio:PublishStencil MenuPath="VisioElectrical\Stencils\Components" />
        </File>
</Component>

I wonder if the problem my stencils and templates still have the "old" suffix's, i.e. vss instead of vssx?
perhaps I should explicitly open each one and re-save them in the "new" format and edit my wxs file?

Thanks
Perry
what, me worry?

Nikolay

That looks fine.. i would try renaming the file to stencil_m.vss first, this if AFAIK the most common case.

It may be also new template (vstx) vs old stencil (vss).
But basically it "should work" :)

perry59

I'll try appending the "_u" to my stencils when I get home tonight and see how that does and let you know in the morning.
Thanks Nikolay!
what, me worry?

perry59

I played around with this a little at work. One thing I noticed that I did not like is the "_U" shows up when browsing stencils.
it does not do that for the ones installed by microsoft, strange.
what, me worry?

Nikolay

#8
This is because the stencils are not installed. You probably just specified the path in the application settings. That is, it looks like Visio discovers you stencils using "path discovery", not installation / registration.
When you install a stencil, you specify a name for it in menu in the "menu path" parameter.
This name is basically what you should see in the menu ("Components" in the case below, "VisioElectrical" and "Stencils" should become parent menu items)

<visio:PublishStencil MenuPath="VisioElectrical\Stencils\Components" />

To test that installation works properly, I would to clear the "path" Visio settings, so that they are blank.

Please note that the stencils with "_U" will show up if you select "US Units" when creating a diagram; stencils with "_M" will show if you select "Metric Units" when creating a diagram.

perry59

Ok. I only renamed them, did not do a re-build and re-install. That's probably the problem.
I'll try that when I get home.
Thanks Nikolay!
what, me worry?

Nikolay

#10
I just did some testing, just to show what it looks like in pictures.
The code includes 4 items: two stencils (metric/us), two templates (metric/us)

      <!-- metric stencil -->
      <Component>
        <File Name="Stencil_1_M.vss">
          <visio:PublishStencil MenuPath="Demo Stencil Folder\Subfolder\Stencil 1 (metric)" />
        </File>
      </Component>
      <!-- metric template -->
      <Component>
        <File Name="Template_1_M.vst">
          <visio:PublishTemplate MenuPath="Demo Stencil Folder\Subfolder\Template 1 (metric)" />
        </File>
      </Component>
      <!-- us stencil -->
      <Component>
        <File Name="Stencil_1_U.vss">
          <visio:PublishStencil MenuPath="Demo Stencil Folder\Subfolder\Stencil 1 (US)" />
        </File>
      </Component>
      <!-- us template -->
      <Component>
        <File Name="Template_1_U.vst">
          <visio:PublishTemplate MenuPath="Demo Stencil Folder\Subfolder\Template 1 (US)" />
        </File>
      </Component>


In the templates you have both (according to the menu path, Templates (tab) => Demo Folder => Subfolder =>


If you create a metric diagram like this:


Then in the menu you have metric stencil (ending with "_m"). Note that "_m" is not displayed, instead the content of the "menu path" is displayed.


Note: there is JUST ONE stencil, although two were registered.
If you select a US template, then you'll see the second stencil in the menu.

The demo project is attached (stencils/templates only no addins)

I believe this whole behavior may be even a bug of some sort.
That is, the thing that in Visio 2013 and above in case a registered stencil has neither "_m" nor "_u" suffix it is not displayed by Visio at all.
I would expect such stencils to show in BOTH cases actually, like it worked in Visio 2010 and below.

In Visio itself, all built-in stencils have either _u or _m prefix (starting with version 2013). My path for example: C:\Program Files (x86)\Microsoft Office\root\Office16\Visio Content\1033
They are just registered by alternative names so taht code like "Documents.Open "Basic.vss" works (note that there are other parameters in <PublishStencil> including this "alternate name" as well.
Visio should be able to find stencil if opened from VBA by any of those names (without path)

perry59

Thanks Nikolay, you da man!
I'll try that out as soon as I can :)
what, me worry?

JohnGoldsmith

Glad you're fixed and will try and be clearer next itme :)
Best regards
John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

Paul Herber

The naming for stencils using _M for metric and _U for US (Imperial) units goes back to early days, I had Visio 2000 and it was in use then.
P.S. the spec I remember used uppercase M and U, don't know how important that is, but I've always used uppercase.
Electronic and Electrical engineering, business and software stencils for Visio -

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

Paul Herber

"Documents.Open "Basic.vss"

Interesting thought, what if another stencil "Basic.vss" gets installed?
Electronic and Electrical engineering, business and software stencils for Visio -

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