Macros not working with SW2013 B1

Just started using this beta version and playing around a bit.

One of the issue is using Macros

I tried few macros which are working nicely in SW2012 SP4, not working with 2013 Beta1

Any suggestions?

OS: Windows 7 64bit

SolidworksSolidworks 2013 Beta
Answers 12
VP
VP 2012-06-28 Best Answer

Hi John,

Would you be able to post an example here ?

Vajrang.

JG
JG 2012-06-29

Hi Vajrang,

Thanks for the reply

First I edit the macros to change the reference to 2013

Still all of the macros I tried, didn't work. SW just freeze

This is one of the macro I downloaded from 3D contentcentral

Please let us know your results

ST
ST 2012-06-29

Works OK for me.

Try changing the line

Set swApp = GetObject("", "SldWorks.Application")

to

Set swApp = Application.SldWorks

There's a chance it is firing up 2012 in the background instead of connecting to the running session of 2013.

AP
AP 2012-06-29

Hi John

Could you please replace following line of code

Set swApp = GetObject("", "SldWorks.Application")

call by

Set swApp = Application.SldWorks

in macro and let me know if this works.

Thanks,
Ajit

ST
ST 2012-06-29

Beat you to it by 2 minutes - do I get the points?!

AP
AP 2012-06-29

yes who is first is always winner..

-Ajit

SF
SF 2012-06-29

Hello John,

Could you please let us know the value of the following registry key:

  HKEY_CLASSES_ROOT\SldWorks.Application\CLSID

It could be either:

  {B4875E89-91F6-4124-BB63-2539727E98FA} => SW2012

  {0D825E02-9000-4D82-B4AB-D6BDC2872797} => SW2013

After you start and exit SolidWorks 2013 has this value changed ?

As you are on Windows 7, is UAC switched on ?

Regards,

  Frank

SF
SF 2012-06-29

Hello Frank,

there is no CLSID for SolidWorks 2013 in the registry, but a shell open command.

that is the content of the key:

[HKEY_CLASSES_ROOT\SldWorks.Application.21] @="SldWorks 2013 Application"

[HKEY_CLASSES_ROOT\SldWorks.Application.21\shell]

[HKEY_CLASSES_ROOT\SldWorks.Application.21\shell\open]

[HKEY_CLASSES_ROOT\SldWorks.Application.21\shell\open\command] @="C:\\PROGRA~1\\SOLIDW~4\\SLDWORKS.exe \"%1\""

Also an external start of SWX with createobject("SldWorks.Application.21") is not possible. In the beta phase of 2012 there was the same problem!

Best regards

Ingo Knoch

JG
JG 2012-06-29

Frank,

HKEY_CLASSES_ROOT\SldWorks.Application\CLSID


shows:  {B4875E89-91F6-4124-BB63-2539727E98FA}

This value remains the same

Does this affect the macros running in SW2013?

Thanks,

JOHN

JG
JG 2012-06-29

Ajith,

Thanks for the solution

It works for this particular Macro after it is changed to:

Set swApp = Application.SldWorks

But my question is: why it makes problem only with 2013?


SF
SF 2012-06-29

Hello John,

Is UAC enabled on your Windows 7 machine ?

I suspect it is and disallows SW2013 to update that registry key which still contains the CLSID for SW2012 after the SW2013 install omitted to set it to the SW2013 value (which we have already reported as the defect to be addressed in SW2013 beta 2).

The net result is that VB functions like CreateObject("SldWorks.Application") and GetObject("","SldWorks.Application"), which rely on the registry, will try to get hold of SW2012 which may no longer be there.

Replacing this with:

  Set swApp = Application.SldWorks

will directly get the running SolidWorks, bypassing the registry as it is built-in to VBA.

If you have administrative permissions and feel comfortable making the change, edit HKCR\SldWorks.Application\CLSID in regedit and replace the SW2012 value with the SW2013 one.

That way you don't have to change your macros.

Regards,

  Frank

SF
SF 2012-07-01

Hello Ingo,

> there is no CLSID for SolidWorks 2013 in the registry

This will be rectified in SW2013 b2.

> Also an external start of SWX with createobject("SldWorks.Application.21") is not possible

This is caused by the above absence of CLSID under HKEY_CLASSES_ROOT\SldWorks.Application.21

> [HKEY_CLASSES_ROOT\SldWorks.Application.21\shell\open\command]

This is by design and part of new functionality in SW2013. From the "What's New":

Selecting a SolidWorks Version When Opening a File

  If you have multiple versions of the SolidWorks software on your machine, and you open

  a SolidWorks file in Windows® Explorer, a dialog box prompts you to select which version to use.

  When you have multiple versions on a machine, the SolidWorks software needs to identify

  which version you prefer to run with the specified file. This is to help prevent any issues with opening files.

Also try a right click on a SolidWorks file in Windows Explorer and look for the "Open With" menu.


Regards,

  Frank