I would like to know if in VBA in Solidworks I have a way to know if the file is backed up? (Before closing it, and if it is not saved, simply leave it open).
Also I would like to know if we have a way to get if the file is read-only or not? (We use EPDM, so if it's read-only it's because we can't save it anyway so we can close it).
I tried this:
Dim instance As IDocumentSpecification Dim value As Boolean Set instance = swApp.GetOpenDocSpec(swModel.GetPathName) Dim Stringi As String Stringi = instance. ReadOnly
But the Debug always tells me false, even if the file is read-only.
Edit: to find out if the document has been saved, I use the GetPathName method , if the variable is empty, it means that it has not been saved yet.
Example:
Set swApp = Application.SldWorks Set CurrentDOC = swApp.ActiveDoc Set swModel = swApp.ActiveDoc Set swConfigMgr = swModel.ConfigurationManager docPath = CurrentDOC.GetPathName If docPath = "" Then MsgBox ("this document has not yet been saved") End if
For the backup I thought about it (I need to do it before the read-only check so I don't have any problems on the way), but this doesn't tell me if the document is "saved", well that there is no longer the little star at the top next to the name on SW:p