Macros and Visual Studio

Programming and macros
User avatar
JSculley
Posts: 643
Joined: Tue May 04, 2021 7:28 am
Answers: 55
x 9
x 877

Macros and Visual Studio

Unread post by JSculley »

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.
User avatar
mattpeneguy
Posts: 1386
Joined: Tue Mar 09, 2021 11:14 am
Answers: 4
x 2489
x 1899

Re: Macros and Visual Studio

Unread post by mattpeneguy »

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.
User avatar
Ömür Tokman
Posts: 359
Joined: Sat Mar 13, 2021 3:49 am
Answers: 1
Location: İstanbul-Türkiye
x 993
x 345
Contact:

Re: Macros and Visual Studio

Unread post by Ömür Tokman »

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.)
You ˹alone˺ we worship and You ˹alone˺ we ask for help.
User avatar
gupta9665
Posts: 410
Joined: Thu Mar 11, 2021 10:20 am
Answers: 25
Location: India
x 433
x 449

Re: Macros and Visual Studio

Unread post by gupta9665 »

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
User avatar
JSculley
Posts: 643
Joined: Tue May 04, 2021 7:28 am
Answers: 55
x 9
x 877

Re: Macros and Visual Studio

Unread post by JSculley »

gupta9665 wrote: Sat Jun 04, 2022 1:01 am I'm using Visual Studio 2022 to create standalone programs and testing on SW22 and have not seen any such issues.
Apps and add-ins aren't the problem (they don't use VSTA). Jut macros.
User avatar
AlexB
Posts: 501
Joined: Thu Mar 18, 2021 1:38 pm
Answers: 28
x 269
x 445

Re: Macros and Visual Studio

Unread post by AlexB »

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
User avatar
JSculley
Posts: 643
Joined: Tue May 04, 2021 7:28 am
Answers: 55
x 9
x 877

Re: Macros and Visual Studio

Unread post by JSculley »

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
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.

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.
User avatar
josh
Posts: 295
Joined: Thu Mar 11, 2021 1:05 pm
Answers: 16
x 22
x 508

Re: Macros and Visual Studio

Unread post by josh »

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.
User avatar
JSculley
Posts: 643
Joined: Tue May 04, 2021 7:28 am
Answers: 55
x 9
x 877

Re: Macros and Visual Studio

Unread post by JSculley »

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.
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.
Post Reply