Visio Guy

Visio => Visio Marketplace & Classified Ads => Topic started by: Nikolay on November 27, 2014, 03:47:00 PM

Title: Visio add-in project templates
Post by: Nikolay on November 27, 2014, 03:47:00 PM
Hello all,

Have just published a bunch of project templates to create a Visio Addin with Visual Studio:

1. COM Addin (C#, works with the free Visual Studio 2013 Community Edition (http://www.visualstudio.com/products/visual-studio-community-vs))
https://visualstudiogallery.msdn.microsoft.com/8c88a77d-ac36-4a03-a39e-4472ba612bee

2. VSTO Addin (C#, requires VSTO)
https://visualstudiogallery.msdn.microsoft.com/d73b91cf-eaf3-4d54-acb5-4a85bec3c1fe

3. C++ Addin. Same thing, but in unmanaged C++ (ATL)
https://visualstudiogallery.msdn.microsoft.com/a9d68071-a0b8-40d1-8ada-fb0f6891c9cb

All of them support:
-       Installer project
-       User interface to start with
-       A TaskPane (not really a "TaskPane", but a docking panel), and a toggle button to control it
-       Custom images for the buttons.
-       State (enabled/disabled) for the buttons.
-       Optional support for legacy Visio version (2003/2007; command bar with buttons)

Here is the screenshot of "Create new project":
(https://i1.visualstudiogallery.msdn.s-msft.com/8c88a77d-ac36-4a03-a39e-4472ba612bee/image/file/147829/1/11-27-2014%209-32-46%20pm.png)

Image of what is the result (checkboxes set like on the picture above):
(https://visualstudiogallery.msdn.microsoft.com/site/view/file/147821/1/11-27-2014%208-52-58%20PM.png)

In Visual Studio:
(http://unmanagedvisio.com/upload/11-27-2014%209-42-35%20PM.png)

Source code at github:
https://github.com/nbelyh/VisioPanelAddinVSTO
https://github.com/nbelyh/VisioPanelAddinCOM
Title: Re: Visio add-in project templates
Post by: Paul Herber on November 27, 2014, 03:49:27 PM
Brilliant stuff, Nikolay. Thanks.
Title: Re: Visio add-in project templates
Post by: Nikolay on November 27, 2014, 04:58:01 PM
Paul, thanks!

Hope that it will work properly and will be useful!
P.S. After publishing found an issue with VSTO project ("No such interface") - should be fixed now. :)
Title: Re: Visio add-in project templates
Post by: Paul Herber on November 28, 2014, 11:30:21 AM
Can't use it myself, unfortunately, as I've uninstalled Visual Studio here completely.
Title: Re: Visio add-in project templates
Post by: Yacine on November 28, 2014, 01:51:07 PM
Hi Nikolay,
from me also the highest appreciation and thanks for the contribution.

I tried the COM version and somehow got stuck, I managed to get till the intaller in "C:\Users\Yacine\Documents\Visual Studio 2013\Projects\VisioPanelAddin1\VisioPanelAddin1\Setup\bin\Debug\x64" and it runs, but I cannot find it in Visio itself.
I seem to be missing an important point.
Title: Re: Visio add-in project templates
Post by: Nikolay on November 28, 2014, 02:24:38 PM
Try to just change to x86 configuration. Most probably that's it. Dont know why Visual Studio sets x64 targets by default.
Just select platform to be x86 in the combo box in VS and rebuild. You should get the installer in the x86 folder.

(http://unmanagedvisio.com/upload/11-28-2014%208-50-17%20PM.png)

The x64 build targets Visio x64...

Probably need to add check for x86/x64 Visio version somewhere in installer.
Also the installer has no UI now, that's probably not okay, would it be better if it had?
Title: Re: Visio add-in project templates
Post by: Yacine on November 28, 2014, 03:15:53 PM
That was the answer.
Thank you.

UI? sure, but a kind of instruction file (readme) could suffice as first help.
Myself and many other forum members would certainly also appreciate a more substantial article or a youtube video on building visio add-ins.

There are still those virtual beers floating around (http://visguy.com/vgforum/index.php?topic=6012.msg24702;topicseen#msg24702 (http://visguy.com/vgforum/index.php?topic=6012.msg24702;topicseen#msg24702)).
I owe you a barrel.
Chris is near Munich. I'll be in charge in Dusseldorf and surroundings. Tell me when ever you come nearby.
Title: Re: Visio add-in project templates
Post by: Yacine on November 28, 2014, 04:09:58 PM
Sorry, but here is already the second question.
Having modified the form in VS and rebuilt the solution, how do I refresh it?
There is still the previous solution showing up.
Title: Re: Visio add-in project templates
Post by: Nikolay on November 28, 2014, 04:38:23 PM
Probably now the installed version is always started.

I do it as following (so that modifications are applied immediately, and you are able to debug / set breakpoints / step through code / etc)

In the Addin's project settings, set the "Register for COM Interop" checkbox.
Also set to start Visio as executable (see below), so the VS does not complain that it cannot start a DLL, but just start Visio.
Rebuild. Run (F5).

Then VS will register the debug version, and Visio will load it instead of the installed one.
Note that you'll need to restart Visual Studio as Administrator do do that:

(http://unmanagedvisio.com/upload/11-28-2014%2010-34-49%20PM.png)

(http://unmanagedvisio.com/upload/11-28-2014 10-44-06%20PM.png)

When you are done debugging, build the installer.
Title: Re: Visio add-in project templates
Post by: Nikolay on December 07, 2014, 04:53:01 AM
Updated:

- Now Visual Basic projects are also supported
- Improved in points encountered by Yacine: now the platform of the installed Visio is selected by default, and Visio is selected as executable to debug by default
- Added default UI to the installer
- Fixed issue with some configurations (error on project creation if some specific combination of checkboxes is selected)
Title: Re: Visio add-in project templates
Post by: Yacine on December 07, 2014, 07:17:51 AM
Just some quick thoughts before even testing the new uploads.


- VB.NET instead of C# is certainly something that will attract more people.
- With your project you are bringing to the visio community a possibility to tweak visio in a much richer and deeper way.
- Being a novice in Visual Studio, I am still struggling with basic structures. I mean knowledge about where (and how) to implement a "visio" class, where one would store the document, page and shapes data; the routines handling the shape inspection and the modification of shape cells; etc.


Regards,
Yacine


PS: how can I de-install a plug-in?

Title: Re: Visio add-in project templates
Post by: Nikolay on December 07, 2014, 11:10:07 AM
Quote
PS: how can I de-install a plug-in?

From Visio: add-remove programs, uninstall.
From Visual Studio: Tools -> Exfensions & Updates -> Uninstall.
Title: Re: Visio add-in project templates
Post by: Yacine on December 07, 2014, 12:06:18 PM
Found it in the control center (is that the right name in english?).


But I found several copies of the addin. That should not happen.
Title: Re: Visio add-in project templates
Post by: Yacine on December 07, 2014, 12:42:22 PM
Hi Nikolay,
it's embarassing for me, because you must get the impression that I am too lazy to search.  :-\


Do you have an idea about what could have caused the attached error?


Basically, Visio starts just fine, no errors, but no toolbar is created.


Update: I messed too much around. After having desintalled the plug-in, I manually deleted also the toolbar. Now neither VB nor C# create a new toolbar. ??? ???


Update 2: If I install the VB plug-in, then I get the toolbar, but there doesn't seem a way to get it in debug mode.
Title: Re: Visio add-in project templates
Post by: Nikolay on December 07, 2014, 07:15:46 PM
Hi Yacine.

Sorry for the inconvenience, not quite sure what the issue is.
You should be able to debug the COM addin as following:

1. Uninstall everything (from add-remove programs).
2. Start Visual Studio as administrator
2. Rebuild the project.
4. Install the project.
5. Set the checkbox "Register for COM interop" in the project settings.
6. Rebuild the project again.
7. Press F5 to start debugging.

Which operating system / Visio version do you have?
Tomorrow I'll try to make a short Video how to make it work..
Title: Re: Visio add-in project templates
Post by: Yacine on December 08, 2014, 01:08:57 AM
Thank you Nikolay,
I hadn't set "Register for COM interop".
Works fine now.
Title: Re: Visio add-in project templates
Post by: Nikolay on December 08, 2014, 09:10:11 AM
Thank you Nikolay,
I hadn't set "Register for COM interop".
Works fine now.

Hi Yacine, good to know!

This is a key point about the registration :)
If you set it, then on build Visual studio registers the DLL at the location where it is, thus overriding what was done in the setup.
In principle, you can set it once, and then remove (so that you can start VS without admin rights)
Or you can register it by hand:

> regasm.exe /codebase <the path to the dll in debug folder>

I think the project should be changed to have this checkbox set by default.
The issue is, you would need to start VS as admin if this checkbox is set (which I thought is bad), but this would definitely help to avoid the confusion.
Visual Studio cannot register a DLL per-user unfortunately.

About the setup - it does not uninstall the previous version, it has "product number" auto-generated now. To block this, you could replace "*" in "productid" with real guid in Product.wxs.
Also, it would be probably better to do it like this for safety by default.
Title: Re: Visio add-in project templates
Post by: Nikolay on March 18, 2015, 01:22:13 PM
It turned out that VSTO projects are also working just fine with Visual Studio 2013 Community Edition.
You need to just install Tools for Office:

http://blogs.msdn.com/b/visualstudio/archive/2014/03/03/announcing-office-developer-tools-for-visual-studio-2013-march-2014-update.aspx
Title: Re: Visio add-in project templates
Post by: Visio Guy on May 26, 2015, 11:38:34 AM
So has anybody gotten this to work with:

1. A VSTO add-in that is made up of MULTIPLE projects (ie: lots of dlls)
2. Stencils, templates and drawintgs
3. Other content files like xml files and Excel files?

I just can't get my head around it. When I try to adapt a Wix project, I cannot tell which GUIDs need to be changed to match the add-in, which names are to match the name of the add-in vs. the name of the .dlls vs. the namespace (sometimes you have spaces, sometimes you have underscores, etc.)

Chris Hopkins tried to add some advise, but the blog post is so incomplete, it doesn't help me at all--it doesn't say where the xml is supposed to go in the file, nor does it state which GUIDs need to be replaced, or what they are for.

http://blogs.msdn.com/b/chhopkin/archive/2013/07/08/wix-for-visio-add-ons-and-content-deployment.aspx

This Wix stuff is maddening, but so is ClickOnce!

Title: Re: Visio add-in project templates
Post by: Visio Guy on September 10, 2015, 06:15:22 AM
Your stuff doesn't seem to show up in Visual Studio 2015. Did Microsoft break a bunch of stuff (again)?
Title: Re: Visio add-in project templates
Post by: Nikolay on September 10, 2015, 06:58:16 AM
Yep, needs to be adopted..
One needs to specify that it works for 2015 explicitly in the package.

Will try to fix this week :)
Title: Re: Visio add-in project templates
Post by: Nikolay on January 15, 2016, 04:08:19 PM
Well, the week turned out to be a long one :)
Anyways, here is the update (published), version 1.0.4:

Update 1.0.4

- added support for Visual Studio 2015

- added support for Visio 2016

- Simplified source code (removed extra files, so that project structure is more like vanilla vs).

- Unified wizard settings. Now there is one wizard to rule it all. It allows you to add (bside the add-in itself) other Visio files/templates in the wizard itself, add license, name/description, etc.

- License support in installer (and wizard).

- Support for the built-in ribbon designer (optional)

- Support for both x86 and x64 in one installer in one MSI (one DLL compiled to "AnyCPU")

- Support per user/per machine install in one MSI (!)

- Support for project auto-harvesting. Means, DLL version is auto-harvested, COM registration auto-harvested (for COM addin type).

- Support for old Visio versions (without ribbon) is still there.

- Improved messaging and comments.

- Possibility to compile everything even witout Visio installed (COM addin only)

- Support for installer UI type selection (basic cases)

- No GUIDs anymore in the installer. All is auto-generated on build.

- Addin project is referenced from installer project using "project reference", so that msbuild variables can be used to refer to paths.

https://visualstudiogallery.msdn.microsoft.com/d73b91cf-eaf3-4d54-acb5-4a85bec3c1fe

Screenshots:
(https://i1.visualstudiogallery.msdn.s-msft.com/d73b91cf-eaf3-4d54-acb5-4a85bec3c1fe/image/file/197389/1/1.png)
(https://i1.visualstudiogallery.msdn.s-msft.com/d73b91cf-eaf3-4d54-acb5-4a85bec3c1fe/image/file/197390/1/2.png)
(https://i1.visualstudiogallery.msdn.s-msft.com/d73b91cf-eaf3-4d54-acb5-4a85bec3c1fe/image/file/197391/1/3.png)

Example: instead of old stuff with a lot of xml text and guids (see here (http://blogs.msdn.com/b/chhopkin/archive/2013/07/08/wix-for-visio-add-ons-and-content-deployment.aspx)), you now can have this:

Code: [Select]
<File Source="$(var.MyAddin.TargetPath)">
  <visio:PublishAddin />
</File>

The name/description of the addin will be read from assembly attributes, the location of the DLL is termined by the project variables.
Title: Re: Visio add-in project templates
Post by: VisioDeveloper on January 25, 2016, 12:19:53 PM
If possible can you provide a line with an example of a checkbox in Ribbon.xml?

The callback function is not being called no matter what i do.

Edit: Nevermind, figured it out

Code: [Select]
<checkBox id="MyCheckBox" getLabel="OnGetRibbonLabel" onAction="OnRibbonButtonCheckClick" getEnabled="IsRibbonCommandEnabled" />
Title: Re: Visio add-in project templates
Post by: Nikolay on January 25, 2016, 02:45:21 PM
About the checkboxes.. In general, the easiest way to go with ribbon designer, not XML. Probably it should be made default in the template in case of VSTO...
I think I need to change the default in the template. Microsoft did a good job of making things simple (see the screenshot below) :)

In case you go with ribbon designer, you just dorp a checkbox from the toolbox, double-click it, and you are done!

Means, don't go with XML unless your really must. A checkbox is definitely not a reason for xml.
The possible reasons I can think of are enabling/disabling or hiding/showing controls dynamically based on current selection for example, or providing dyanmic or icons for the controls.

Anyways, with the XML - you are correct, <checkBox> should do. The thing is, in the template ribbon handlers are in the AddinUI class (not "ThisAddIn")
They redirect to ThisAddIn class.
Title: Re: Visio add-in project templates
Post by: Nikolay on February 06, 2016, 01:17:24 PM
Updated to version 1.0.7:

- New: improved support for non-english locales. Now you can select language of the installer in the wizard. Rrequired, if want to produce installer in non-english language, or if you use non-english symbols for your stencil/template file names, like symbols with umlauts, like "è é ê ë" or cyrilic symbols like "абвгд".

- New: added "manufacturer" field in the wizard (to be shown on install/uninstall)

Title: Re: Visio add-in project templates
Post by: Nikolay on November 12, 2017, 01:03:04 PM
Updated project template to v 1.1.0:

- Added support for Visual Studio 2017 (https://marketplace.visualstudio.com/items?itemName=NikolayBelyh.ExtendedVisioAddinProject2017) (this one appeared to be pretty tough :)) )
- Fix wizard for high-DPI (4k / "retina") monitors.
- Some Visio 2007 - related fixes in the installer.