BC30455 Argument not specified for parameter

I cant set swModel = swApp.ActiveDoc
Here is the code;

Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports SolidWorks.Interop.swpublished
Public Class Macro
    Public Sub [command1]()
        Dim CList_100 As String
        Dim Ccount_100 As Integer
        Dim nComponents As Integer
        Dim nStart As Single
        Dim bRet As Boolean
        Dim swApp As SldWorks = CreateObject("Sldworks.application")
        Dim swModel As SolidWorks.Interop.sldworks.ModelDoc2
        Dim swAssy As SolidWorks.Interop.sldworks.AssemblyDoc
        Dim swConf As SolidWorks.Interop.sldworks.Configuration
        Dim swRootComp As SolidWorks.Interop.sldworks.Component2
        swModel = swApp.ActivateDoc
        swConf = swModel.GetActiveConfiguration
        swRootComp = swConf.GetRootComponent3(True)
        Debug.Print("File = " & swModel.GetTitle)
        TraverseComponent swRootComp, 1
        Debug.Print("Finished!")
    End Sub
End Class

Here is the error message;
BC30455 Argument not specified for parameter ‘Name’ of 'Function ActivateDoc(Name As String) As Object

I think you meant to type “ActiveDoc” instead of “ActivateDoc”.

The latter expects you to provide the path of the document as the argument which is why you’re getting this error.

1 Like

I did this its worked but ı dont know user file name? parts name depends to user
swModel = swApp.ActivateDoc(“part1.sldprt”)

also there is some error to;
This not works;
Dim swApp As SldWorks.SldWorks
Dim swModel As Sldworks.ModelDoc2
it must be type like this;
Dim swApp As SldWorks = CreateObject(“Sldworks.application”)
Dim swModel As SolidWorks.Interop.sldworks.ModelDoc2
and also

The examples that use VBA that the help documentation show are assuming you’re using the built-in macro editor.

If you’re using a custom VB.NET project, you’ll have to import the DLLs into your project and create a reference to Solidworks as you’ve shown.

Placing this at the top of your class document that uses the DLLs should allow you to remove the SolidWorks.Interop.sldworks portion of all your type names.

Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst