I have created a macro to automate different versions of a product for a customer, the macro works fine, except for the end. The macro should open several files, change the dimensions and make a 'save as' and close all files in the end.
It work on my workstation, but when I run the macro on the customers worksstation, the files aren't closed at the end. I use a 'swApp.CloseDoc' to close the file.
Could anyone help me with this?
SolidworksApi macros
Try QuitDoc Method (ISldWorks)
Do you mean replace 'swApp.CloseDoc' with 'swApp.Quitdoc' ?
yes...
No, unfortunately it doesn't work. At my workstation it closes the drawing after the macro, at the other workstation the drawing is still open...
Unless you need for certain documents to remain open, try ISldWorks::CloseAllDocuments.
Also, ISldWorks::CloseDoc and ISldWorks::QuitDoc can possibly close the wrong document if you have two documents with the same base name open and the user has "Show extensions of known file types" turned on in their Windows folder options. That option is located here:
In other words, if this was turned on, and you had "MyDoc.SLDDRW" and "MyDoc.SLDPRT" open at the same time and ran ISldWorks::QuitDoc or ISldWorks::CloseDoc for "MyDoc" or IModelDoc2::GetTitle, then the wrong document could possibly be closed. This is why you should always extract the full file name from IModelDoc2::GetPathName.
Keith
SolidWorks API Tutorials
Thanks Keith, that's it! I never would have found that solution.