Macros and Visual Studio
Macros and Visual Studio
After some research and testing, I think that the answer is no, but I want to be sure, so I'll as the question.
Is anyone developing SW macros using .NET with SW 2022 and a version of Visual Studio newer than 2015?
From what I can tell, SW 22 is hard wired to use Visual Studio 2015. If it isn't installed, I simply can't create or edit .NET macros. The folders and files will be created but the Visual Studio editor will not start. As soon as I install Visual Studio 2015 and then do a Repair on Visual Studio Tools for Applications 2015, it works as expected.
Is anyone developing SW macros using .NET with SW 2022 and a version of Visual Studio newer than 2015?
From what I can tell, SW 22 is hard wired to use Visual Studio 2015. If it isn't installed, I simply can't create or edit .NET macros. The folders and files will be created but the Visual Studio editor will not start. As soon as I install Visual Studio 2015 and then do a Repair on Visual Studio Tools for Applications 2015, it works as expected.
- mattpeneguy
- Posts: 1386
- Joined: Tue Mar 09, 2021 11:14 am
- x 2489
- x 1899
Re: Macros and Visual Studio
I'd guess @josh, @gupta9665, or @artem would be able to answer that for you. Seems like a dated version of .NET to be tied to...But, there may be a reason.
- Ömür Tokman
- Posts: 359
- Joined: Sat Mar 13, 2021 3:49 am
- Location: İstanbul-Türkiye
- x 993
- x 345
- Contact:
Re: Macros and Visual Studio
As far as I know, macros are limited features, so VBA is sufficient.
VS (c#, "vb") is used to use many innovations and differences.
Example: Ribbon menu, FeatureManager, plugin, sw independent sw utilities.
Maybe when VBA isn't enough for a simple macro. (QR code etc.)
VS (c#, "vb") is used to use many innovations and differences.
Example: Ribbon menu, FeatureManager, plugin, sw independent sw utilities.
Maybe when VBA isn't enough for a simple macro. (QR code etc.)
You ˹alone˺ we worship and You ˹alone˺ we ask for help.
Re: Macros and Visual Studio
I'm using Visual Studio 2022 to create standalone programs and testing on SW22 and have not seen any such issues.
Deepak Gupta
SOLIDWORKS Consultant/Blogger
SOLIDWORKS Consultant/Blogger
Re: Macros and Visual Studio
This is the most info I've found about it. Looks like it might be possible, but you need a runtime version of 2015 installed still.
https://help.solidworks.com/2021/englis ... A_2015.htm
https://help.solidworks.com/2021/englis ... A_2015.htm
Re: Macros and Visual Studio
Yeah. I've tried all that. I went so far as to download the VSTA SDK to understand how it actually works. You create an application and reference the VSTA library version 20XX. When you have your app make a call to create the IDE, it will open the matching Visual Studio version. I can change the VSTA library version in my app's references, and it will open the matching Visual Studio version.AlexB wrote: ↑Mon Jun 06, 2022 8:45 am This is the most info I've found about it. Looks like it might be possible, but you need a runtime version of 2015 installed still.
https://help.solidworks.com/2021/englis ... A_2015.htm
image.png
So, SW is built with a reference to VSTA 2015, and if Visual Studio 2015 isn't there, it won't work.
Also, there isn't even a 2022 version of VSTA, so the latest version of Visual Studio that could be used if SW updated their code to referenced the latest VSTA library would be 2019. So either way, I would need to install two different versions of Visual Studio which is what I was trying to avoid in the first place.
Re: Macros and Visual Studio
Unfortunately, VSTA seems to be some sort of bastard child. When it first came out, I thought it was gonna be the bees knees, but I ended up having stability problems using it where the same thing in VBA ran just fine. I read of real programmers having issues with it as well - specifically Artem and Keith if I remember right. I'm pretty sure they both recommend against using VSTA macros, and using either VBA (for simple stuff) or full add-ins, which should be possible for you since it sounds like you're running full Visual Studio. I know the .net tools are way more robust/powerful/flexible and VBA is way old and ugly and everyone hates it, but from everything I've heard VSTA is the middle ground that just isn't a great place to stand.
Re: Macros and Visual Studio
Yeah for anything 'real' I'll typically whip up an add-in. But sometimes I just want to do a quick test or post some code to solve a forum question, so macros are quick and easy. Doing them in C# is far more natural to me, hence my desire for VSTA working with my current Visual Studio 2022. But for now, I've got 2022 and 2015 installed, so at least I'm not dead in the water.josh wrote: ↑Mon Jun 06, 2022 11:43 am Unfortunately, VSTA seems to be some sort of bastard child. When it first came out, I thought it was gonna be the bees knees, but I ended up having stability problems using it where the same thing in VBA ran just fine. I read of real programmers having issues with it as well - specifically Artem and Keith if I remember right. I'm pretty sure they both recommend against using VSTA macros, and using either VBA (for simple stuff) or full add-ins, which should be possible for you since it sounds like you're running full Visual Studio. I know the .net tools are way more robust/powerful/flexible and VBA is way old and ugly and everyone hates it, but from everything I've heard VSTA is the middle ground that just isn't a great place to stand.