GetDocuments returns a Variant, so your Dim statement should read:
Dim openDocs as Variant
When you have problems like this it is always a good idea to look at the API Help. There are eaxmples for many of the API calls that make it easy to determine where you may have gone wrong.
That fixed that problem. I try my best to understand the api help but unfortunately i have very little konwledge of programing and i have just in the last month been trying to learn VBA for solidworks so often times it makes no sense to me.
now i have an error at:
For Each currentModel In openDocs.
why would that be?
See the changes in red
Dim openDocs As Variant
Dim swPartDoc As PartDoc
Dim swAssemblyDoc As AssemblyDoc
Dim currentModel As Variant
Dim partFileName As String
openDocs = swApp.GetDocuments()
For Each currentModel In openDocs
If (currentModel.GetType = swDocumentTypes_e.swDocASSEMBLY) Then
swAssemblyDoc = currentModel
If (currentModel.GetType = swDocumentTypes_e.swDocPART) Then
Set swPartDoc = currentModel
partFileName = swPartDoc.GetPathName()
Artem Taturevych, Application Engineer at Intercad (Australia)
translationXpert – add-in to translate SolidWorks models
myIntercad – an integrated tool for SolidWorks Professionals
Thank you. Works great
What would i have to do to make it check if an assembly is open?