Hi Handleman
Thank you so far for your help. Your macro has opened up solidworks, but when I add on the rest of the macro that was recorded by solidworks itself, nothing else happens.
Ie solidoworks opens and that it - no errors are reported
here is the full code as I am trying to run from excel
Sub StartNewPartFromExcel()
Dim swApp As SldWorks.SldWorks
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Const ERR_APP_NOTFOUND As Long = 429
On Error Resume Next
Set swApp = GetObject(, "SldWorks.Application")
If Err.Number = ERR_APP_NOTFOUND Then
Set swApp = New SldWorks.SldWorks
swApp.UserControl = True
End If
swApp.NewPart
Set swApp = Nothing
' from here down, the macro comes from SW
Set swApp = Application.SldWorks
Set Part = swApp.NewDocument("C:\Program Files\SolidWorks Corp\SolidWorks\lang\english\Tutorial\part.prtdot", 0, 0, 0)
swApp.ActivateDoc2 "Part4", False, longstatus
Set Part = swApp.ActiveDoc
Dim myModelView As Object
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
boolstatus = Part.Extension.SelectByID2("Front", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Dim skSegment As Object
Set skSegment = Part.SketchManager.CreateCircle(0.03616, 0.021024, 0#, 0.027669, 0.014151, 0#)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0.03454268968685, 0.03153595505618, 0, False, 0, Nothing, 0)
Dim myDisplayDim As Object
Set myDisplayDim = Part.AddDimension2(-0.007505250388061, 0.04265440074906, 0)
Part.ClearSelection2 True
Dim myDimension As Object
Set myDimension = Part.Parameter("D1@Sketch1")
myDimension.SystemValue = 0.0123
Part.ShowNamedView2 "*Trimetric", 8
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("D1@Sketch1@Part4.SLDPRT", "DIMENSION", 0, 0, 0, False, 0, Nothing, 0)
Dim myFeature As Object
Set myFeature = Part.FeatureManager.FeatureExtrusion2(True, False, False, 0, 0, 0.014, 0.01, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, True, True, True, 0, 0, False)
Part.SelectionManager.EnableContourSelection = False
End Sub
any thoughts as what I still need to do to get it to draw and extrude?