I am working on the Design Bilner macro and facing some issues with the code. Could you take a look and help me?
- Solidworks has a feature called “Design Binder”. The function of this is to store the active model’s details example – File name, description, and material
- Once the model is used to generate the child models it's calling the file details to the child I wanna deleted the design binder and make it empty.
Requirement:
Step 1. Macro has to select the feature “Design Journal.doc” and if it’s not empty.
Step 2. Right and Delete the Design Binder.
Step 3. The updated design binder should show "Design Journal ".
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim fileerror As Long
Dim filewarning As Long
Dim bool1 As Boolean
Dim FileName As String
'Main function
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModelDocExt = swModel.Extension
'Check the solidworks had the files opened
If swModel Is Nothing Then
MsgBox "No active documents open in solidworks"
Exit Sub
End If
' Show the Design Binder in the FeatureManager design tree
bool1 = swApp.SetUserPreferenceIntegerValue(swFeatureManagerDesignBinderVisibility, swAutoHideShowResponse_Show)
'OLE - Object Linked and Embeded. As Word is the OLE object it need to searched in the design tree
VOleObjsCount = swModelDocExt.GetOLEObjectCount(oleobjoptions)
' If the Design Journel is updated then the below if condition is executed . If the design bilder is empty Else Condition
If VOleObjsCount > 0 Then
vOleObjs = swModelDocExt.GetOLEObjects(oleobjoptions)
ub = UBound(vOleObjs)
For i = 0 To ub
vOleObjs(i).Select False
swModel.EditDelete
Debug.Print "Deleted now"
Next i
swModel.ClearSelection2 True
swModel.ForceRebuild3 True
Else
Debug.Print "There are no OLE attachments found"
End If
End Sub