How to set oneself Material ?

Set Material Property Name Example (VB)

This example shows how to set a part's material property name.

http://help.solidworks.com/2012/English/api/sldworksapi/set_material_property_name_example_vb.htm

'Set Material Property Name Example (VB)

'This example shows how to set a part's material property name.

'------------------------------------------------------------------

'

' Preconditions: Part document is open.

'

' Postconditions: Model and part material property name changed to Alloy Steel.

'

'------------------------------------------------------------------

'Option Explicit

Sub main2()

    Dim swApp                       As SldWorks.SldWorks

    Dim swModel                     As SldWorks.ModelDoc2

    Dim swPart                      As SldWorks.PartDoc

    Dim i                           As Long

    Dim bRet                        As Boolean

   

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swPart = swModel

   

    Debug.Print "File = " & swModel.GetPathName

    Debug.Print "  Old model material   = " & swModel.MaterialIdName

    Debug.Print "  Old part  material   = " & swPart.MaterialIdName

   

    ' Apply new material. This operation overwrites the information in

    ' ModelDoc2::MaterialIdName and PartDoc::MaterialIdName.

    swPart.SetMaterialPropertyName "SolidWorks Materials.sldmat", "Alloy Steel"

   

    Debug.Print "  New model material   = " & swModel.MaterialIdName

    Debug.Print "  New part  material   = " & swPart.MaterialIdName

End Sub

'---------------------------------------

Help me,

swPart.SetMaterialPropertyName "SolidWorks Materials.sldmat", "Alloy Steel"

How to change sldmat, set oneselft material.

Thanks .

http://help.solidworks.com/2012/English/api/sldworksapi/get_and_set_material_visual_properties_example_vb.htm

SolidworksApi macros