Private Sub Command1_Click()
Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Dim M As Single
Dim d As Single
Dim p As Single
Dim q As Single
Dim q1 As Single
Dim qq As Single
Dim SweepFeature As Object
Dim X1 As Single
Dim X2 As Single
Set swApp = CreateObject("SldWorks.application")
Set Part = swApp.NewDocument("D:\\ProgramFiles\\SolidWorks\\lang\\chinese-simplified\\Tutorial\\part.prtdot", 0,0#, 0#)
Set Part = swApp.ActivateDoc2("Part1", False, longstatus)
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
Const pi = 3.141592654
M = 20 '????
d = 2 '????
p = 6 '??
q = 25 '??????,??????
q1 = 2 '????????
qq = 2 * q1
'h = p * q + q1 * d * 2 '????,q????
'?????
'???
boolstatus = Part.Extension.SelectByID2("?????", "PLANE", 0, 0, 0,False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Part.CreateCircle 0, M / 2, 0, 0, M / 2 + d / 2, 0
'???
boolstatus = Part.Extension.SelectByID2("?????", "PLANE", 0, 0, 0,False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Part.CreateCircle 0, 0, 0, M / 2, 0, 0
'?????
Part.InsertHelix False, False, False, True, 0, 0.01875, p, q, 0,1.570796326795
'??????
'???
boolstatus = Part.Extension.SelectByID2("?????", "PLANE", 0, 0, 0,False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Part.CreateCircle -p * q, M / 2, 0, -p * q, M / 2 + d / 2, 0
Part.ClearSelection2 True
'?????
boolstatus = Part.Extension.SelectByID2("?????", "PLANE", 0, 0, 0,False, 0, Nothing, 0)
Part.CreatePlaneAtOffset3 p * q, False, True
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
'???
boolstatus = Part.Extension.SelectByID2("???1", "PLANE", 0, 0, 0,False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Part.CreateCircle 0, 0, 0, M / 2, 0, 0
'?????
Part.InsertHelix False, False, False, True, 0, 0.01875, d + 0.05,qq, 0, 1.570796326795
'??????
'???
boolstatus = Part.Extension.SelectByID2("?????", "PLANE", 0, 0, 0,False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Part.CreateCircle 0, M / 2, 0, 0, M / 2 + d / 2, 0
'???
boolstatus = Part.Extension.SelectByID2("?????", "PLANE", 0, 0, 0,False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Part.CreateCircle 0, 0, 0, M / 2, 0, 0
'?????
Part.InsertHelix True, True, False, True, 0, 0.01875, d + 0.05, qq,0, 1.570796326795
'?????????
boolstatus = Part.Extension.SelectByID2("??1", "SKETCH", 0, 0, 0,False, 1, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("???/???1","REFERENCECURVES", 0, 0, 0, True, 4, Nothing, 0)
Set SweepFeature =Part.FeatureManager.InsertProtrusionSwept3(False, False, 0, False,False, 0, 0, False, 0, 0, 0, 0, 1, 1, 1, 0, 1)
'??????????
boolstatus = Part.Extension.SelectByID2("??3", "SKETCH", 0, 0, 0,False, 1, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("???/???2","REFERENCECURVES", 0, 0, 0, True, 4, Nothing, 0)
Set SweepFeature =Part.FeatureManager.InsertProtrusionSwept3(False, False, 0, False,False, 0, 0, False, 0, 0, 0, 0, 1, 1, 1, 0, 1)
'??????????
boolstatus = Part.Extension.SelectByID2("??5", "SKETCH", 0, 0, 0,False, 1, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("???/???3","REFERENCECURVES", 0, 0, 0, True, 4, Nothing, 0)
Set SweepFeature =Part.FeatureManager.InsertProtrusionSwept3(False, False, 0, False,False, 0, 0, False, 0, 0, 0, 0, 1, 1, 1, 0, 1)
'????
boolstatus = Part.Extension.SelectByID2("?????", "PLANE", 0, 0, 0,False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
X1 = (d * qq) / 2
X2 = X1 + d * qq * 2
Part.CreateLine2 X1, (M + d) / 2, 0, X2, (M + d) / 2, 0
Part.CreateLine2 X2, (M + d) / 2, 0, X2, -(M + d) / 2, 0
Part.CreateLine2 X2, -(M + d) / 2, 0, X1, -(M + d) / 2, 0
Part.CreateLine2 X1, -(M + d) / 2, 0, X1, (M + d) / 2, 0
X1 = -p * q - (d * qq) / 2
X2 = X1 - d * qq * 2
Part.CreateLine2 X1, (M + d) / 2, 0, X2, (M + d) / 2, 0
Part.CreateLine2 X2, (M + d) / 2, 0, X2, -(M + d) / 2, 0
Part.CreateLine2 X2, -(M + d) / 2, 0, X1, -(M + d) / 2, 0
Part.CreateLine2 X1, -(M + d) / 2, 0, X1, (M + d) / 2, 0
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Line8", "SKETCHSEGMENT",0, 0, 0, False, 0, Nothing, 0)
Part.FeatureManager.FeatureCut True, False, False, 6, 0, M + d,0.01, False, False, False, False, 0.01745329251994,0.01745329251994, False, False, False, False, 0, 1, 1
Part.SelectionManager.EnableContourSelection = 0
'??
boolstatus = Part.SetUserPreferenceToggle(198, True)
Part.ShowNamedView2 "*???????", 8
Part.ViewZoomtofit2
'?sw???dwg??,*???????/1000,??1:1??
End SubSolidworksApi macros
Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Dim M As Single
Dim d As Single
Dim p As Single
Dim q As Single
Dim q1 As Single
Dim qq As Single
Dim SweepFeature As Object
Dim X1 As Single
Dim X2 As Single
Set swApp = CreateObject("SldWorks.application")
Set Part = swApp.NewDocument("D:\\ProgramFiles\\SolidWorks\\lang\\chinese-simplified\\Tutorial\\part.prtdot", 0,0#, 0#)
Set Part = swApp.ActivateDoc2("Part1", False, longstatus)
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
Const pi = 3.141592654
M = 20 '????
d = 2 '????
p = 6 '??
q = 25 '??????,??????
q1 = 2 '????????
qq = 2 * q1
'h = p * q + q1 * d * 2 '????,q????
'?????
'???
boolstatus = Part.Extension.SelectByID2("?????", "PLANE", 0, 0, 0,False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Part.CreateCircle 0, M / 2, 0, 0, M / 2 + d / 2, 0
'???
boolstatus = Part.Extension.SelectByID2("?????", "PLANE", 0, 0, 0,False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Part.CreateCircle 0, 0, 0, M / 2, 0, 0
'?????
Part.InsertHelix False, False, False, True, 0, 0.01875, p, q, 0,1.570796326795
'??????
'???
boolstatus = Part.Extension.SelectByID2("?????", "PLANE", 0, 0, 0,False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Part.CreateCircle -p * q, M / 2, 0, -p * q, M / 2 + d / 2, 0
Part.ClearSelection2 True
'?????
boolstatus = Part.Extension.SelectByID2("?????", "PLANE", 0, 0, 0,False, 0, Nothing, 0)
Part.CreatePlaneAtOffset3 p * q, False, True
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
'???
boolstatus = Part.Extension.SelectByID2("???1", "PLANE", 0, 0, 0,False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Part.CreateCircle 0, 0, 0, M / 2, 0, 0
'?????
Part.InsertHelix False, False, False, True, 0, 0.01875, d + 0.05,qq, 0, 1.570796326795
'??????
'???
boolstatus = Part.Extension.SelectByID2("?????", "PLANE", 0, 0, 0,False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Part.CreateCircle 0, M / 2, 0, 0, M / 2 + d / 2, 0
'???
boolstatus = Part.Extension.SelectByID2("?????", "PLANE", 0, 0, 0,False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Part.CreateCircle 0, 0, 0, M / 2, 0, 0
'?????
Part.InsertHelix True, True, False, True, 0, 0.01875, d + 0.05, qq,0, 1.570796326795
'?????????
boolstatus = Part.Extension.SelectByID2("??1", "SKETCH", 0, 0, 0,False, 1, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("???/???1","REFERENCECURVES", 0, 0, 0, True, 4, Nothing, 0)
Set SweepFeature =Part.FeatureManager.InsertProtrusionSwept3(False, False, 0, False,False, 0, 0, False, 0, 0, 0, 0, 1, 1, 1, 0, 1)
'??????????
boolstatus = Part.Extension.SelectByID2("??3", "SKETCH", 0, 0, 0,False, 1, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("???/???2","REFERENCECURVES", 0, 0, 0, True, 4, Nothing, 0)
Set SweepFeature =Part.FeatureManager.InsertProtrusionSwept3(False, False, 0, False,False, 0, 0, False, 0, 0, 0, 0, 1, 1, 1, 0, 1)
'??????????
boolstatus = Part.Extension.SelectByID2("??5", "SKETCH", 0, 0, 0,False, 1, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("???/???3","REFERENCECURVES", 0, 0, 0, True, 4, Nothing, 0)
Set SweepFeature =Part.FeatureManager.InsertProtrusionSwept3(False, False, 0, False,False, 0, 0, False, 0, 0, 0, 0, 1, 1, 1, 0, 1)
'????
boolstatus = Part.Extension.SelectByID2("?????", "PLANE", 0, 0, 0,False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
X1 = (d * qq) / 2
X2 = X1 + d * qq * 2
Part.CreateLine2 X1, (M + d) / 2, 0, X2, (M + d) / 2, 0
Part.CreateLine2 X2, (M + d) / 2, 0, X2, -(M + d) / 2, 0
Part.CreateLine2 X2, -(M + d) / 2, 0, X1, -(M + d) / 2, 0
Part.CreateLine2 X1, -(M + d) / 2, 0, X1, (M + d) / 2, 0
X1 = -p * q - (d * qq) / 2
X2 = X1 - d * qq * 2
Part.CreateLine2 X1, (M + d) / 2, 0, X2, (M + d) / 2, 0
Part.CreateLine2 X2, (M + d) / 2, 0, X2, -(M + d) / 2, 0
Part.CreateLine2 X2, -(M + d) / 2, 0, X1, -(M + d) / 2, 0
Part.CreateLine2 X1, -(M + d) / 2, 0, X1, (M + d) / 2, 0
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Line8", "SKETCHSEGMENT",0, 0, 0, False, 0, Nothing, 0)
Part.FeatureManager.FeatureCut True, False, False, 6, 0, M + d,0.01, False, False, False, False, 0.01745329251994,0.01745329251994, False, False, False, False, 0, 1, 1
Part.SelectionManager.EnableContourSelection = 0
'??
boolstatus = Part.SetUserPreferenceToggle(198, True)
Part.ShowNamedView2 "*???????", 8
Part.ViewZoomtofit2
'?sw???dwg??,*???????/1000,??1:1??
End SubSolidworksApi macros

You need to help us help you here...
First of all you need to replace the "?" with what they are meantto be and also it would be good if you could indicate where you getthe runtime error...
Cheers,
--Stav.
Is this from the English version of SolidWorks? Maybe thecopy/paste into the forum changed all the foreign characters to ???marks.