Search code examples
ms-accessreferencesolidworks

Solidworks 2016 SaveAs Access VBA Run-time error 438


I have a MS Access VBA script that configures SolidWorks parts in different ways.

After upgrade to Windows 10 as well as SolidWorks 2016, it no longer works.

My code is:

Set swApp = CreateObject("SldWorks.Application")
Set part = swApp.activeDoc
bRet = swApp.SaveAs4(Savename, swSaveAsCurrentVersion, swSaveAsOptions_Copy, nErrors, nWarnings)

Where Savename is "C:\test-part.SLDPRT"

It stops at the SwApp.SaveAs4

I get Run-time error '438'. "Object does not support this property or method".

I have tried Save, SaveAs2 etc. but same error.

I can't find anything about this yet.

Any suggestions?

BR, Emil.


Solution

  • Try:

    bRet = part.SaveAs4(Savename, swSaveAsCurrentVersion, swSaveAsOptions_Copy, nErrors, nWarnings)

    You need to save the part, not the application.