I have downloaded a swb file from a vendor and when I try to run it by running macro I get the attached error message, any suggestions.
Most probably, missing references. Can you attach the file here to check
Code worked fine for me in SW2016. Press the Debug button and take a screen shot of where in the code the macro hung.
There could be two issue:
1. Several variables are not defined. So comment Option explicit on the top of the macro.
2. Macro is being used on x64 bit machine and these deceleration showing error. So either comment them out or add PtrSafe
There is no Option Explicit statement in the macro and it appears that the code is written to work both on 32 bit and 64 bit machines using an #If VBA7 statement which I am not familiar with.
I got the Option Explicit when I edited it. And since most people are using x64 bit machines, so the codes for x32 can be taken off.
No Option Explicit when I open the macro in SW2016 or SW2014 (and when I open it in notepad). Do you have your VBA setup to automatically add this statement?
While I agree that the 32bit code is not needed on 64bit machines, I have not found it to be an issue. I have run the macro on a Win7 and Win8.1 (both 64bit) and do not get the Run time error 91. This is why I asked him to take a screen shot after pressing debug so we can see where the code stopped.
I put a stop point in the macro so it would run until the first time it got to the statement that is highlighted in your screenshot. The screen shot below shows the model that is created in SolidWorks. Do you get the same results when the macro fails? If not then I have a couple of questions for you and one request.
The error you are getting seems to indicate that the part object is not valid but for the macro to get that far in the code, it should have failed long before that. That is why I ask how you start the macro.
I found the problem. It was looking for my part and assembly templates which it could not find. I corrected the location of my default templates and that solved the problem. Thanks for your help.
Glad you found the solution. Unfortunately, it does not solve it for me. I thought once that it was not finding the default templates but after renaming the templates file and running the macro the code failed before getting to where it failed for you. Now I am left to wonder why your code failed for you where it did.
Solid Air wrote: Do you have your VBA setup to automatically add this statement?
Solid Air wrote:
Do you have your VBA setup to automatically add this statement?
I think yes.
Retrieving data ...