0
\$\begingroup\$

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. Design Binder With Data Step 2. Right and Delete the Design Binder. enter image description here Step 3. The updated design binder should show "Design Journal ". enter image description here

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
\$\endgroup\$
1
  • 1
    \$\begingroup\$ "facing some issues with the code" What kind of issues are you facing? Does the code do what you require it to do? \$\endgroup\$
    – Mast
    Aug 30, 2022 at 14:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.