Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime Error 2147417851

Status
Not open for further replies.

Eurobum

Aerospace
Aug 20, 2001
27
Hello All,

I'm new here and to VBA too. I wrote some codes in VBA using Excel. It works fine with SolidWorks 2007 SP0. Once I upgraded to SP2.2 my code bounced back with the Runtime Error 2147417851 (80010105).
I did check all the Reference Libraries. They are fine. My guess is I'm having a binding issue.

Could any Guru out there lend me some tips to solve this problem?. TIA.

Here's a portion of my code and it stops at the last line


Option Explicit



Private Sub Update_Click()



Const swDocPart = 1

Const swDocAssembly = 2

Const swDocDrawing = 3

Const swDwgTemplateCustom = 12

Const swDwgTemplateNone = 13



Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swLayerMgr As SldWorks.LayerMgr

Dim swLayer As SldWorks.Layer

Dim DrawingDoc As Object

Dim SheetNames As Variant

Dim SheetProperties As Variant

Dim Sheet As Object

Dim Path As String

Dim Partfile As String



Dim Part As Object

Dim SelMgr As Object

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

Dim Feature As Object



'Set path for file location

Path = "C:\AutoTemplate\"

If Range("H2").Value < 10 Then

Partfile = Range("AT12").Value

Range("C15").Value = " 13.5 in x "

Else

Partfile = Range("AT13").Value

Range("C15").Value = " 15.5 in x "

End If



'Attach to or start SolidWorks session

Set swApp = CreateObject("SldWorks.Application")



'Load drawing

Set swModel = swApp.OpenDoc(Path + Partfile, swDocDrawing)



Set Part = swApp.ActiveDoc

Set SelMgr = Part.SelectionManager

swApp.ActiveDoc.ActiveView.FrameLeft = 0

swApp.ActiveDoc.ActiveView.FrameTop = 0

swApp.ActiveDoc.ActiveView.FrameState = 1

Set Part = swApp.ActivateDoc2(Partfile, False, longstatus)



Dim retval As Boolean

Dim Note As SldWorks.Note

Dim Annotation As SldWorks.Annotation

Dim View As SldWorks.View

Dim DocType As Object

Dim FormatObj As Object

Dim FontName As String

Dim Setting As Variant



Dim sheetformatpath(12) As String

Dim Name As String

Dim paperSize As Long

Dim scale1 As Double

Dim scale2 As Double

Dim firstAngle As Boolean

Dim templateIn As Long

Dim TemplateName As String

Dim Width As Double

Dim Height As Double

Dim AdjustHeight As Double

Dim propertyViewName As String

Dim i As Long

Dim eye As Integer

Dim NumSheet As Long



Dim OldHiddenSeal_1 As Double

Dim OldBackPanel_1 As Double

Dim OldSidePanel_1 As Double

Dim OldFrontPanel As Double

Dim OldHiddenSeal_2 As Double

Dim OldBackPanel_2 As Double

Dim OldSidePanel_2 As Double

Dim OldWeb As Double

Dim NewHiddenSeal_1 As Double

Dim NewBackPanel_1 As Double

Dim NewSidePanel_1 As Double

Dim NewFrontPanel As Double

Dim NewHiddenSeal_2 As Double

Dim NewBackPanel_2 As Double

Dim NewSidePanel_2 As Double

Dim NewWeb As Double



Application.Cursor = xlWait



Set SelMgr = Part.SelectionManager

Set View = Part.GetFirstView()

Set swModel = swApp.ActiveDoc

Set swLayerMgr = swModel.GetLayerManager

Set DrawingDoc = swApp.ActiveDoc

Set Part = swApp.ActiveDoc



SheetNames = DrawingDoc.GetSheetNames

Range("AT16").Value = SheetNames



If Range("AT16").Value <> Range("AT15").Value Then

MsgBox "Template Not Found"

Application.Cursor = xlDefault

End

End If



OldHiddenSeal_1 = Part.Parameter("D9@Sketch1").SystemValue / 0.0254

OldBackPanel_1 = Part.Parameter("D5@Sketch1").SystemValue / 0.0254

OldSidePanel_1 = Part.Parameter("D6@Sketch1").SystemValue / 0.0254

OldFrontPanel = Part.Parameter("D8@Sketch1").SystemValue / 0.0254

OldHiddenSeal_2 = Part.Parameter("D1@Sketch1").SystemValue / 0.0254

OldBackPanel_2 = Part.Parameter("D7@Sketch1").SystemValue / 0.0254

OldSidePanel_2 = Part.Parameter("D104@Sketch1").SystemValue / 0.0254



Part.Parameter("D9@Sketch1").SystemValue = Range("a2").Value * 0.0254

 
Replies continue below

Recommended for you

Eurobum,

Are you working over a network? Have you re-booted your system and tried again? Does your code open the models as expected? Does the model actually have a "D9@Sketch1" dimension? Add a check to see that before that last call is made, the Part object is still valid. I also left you a reply in the SolidWorks forum.

SA
 
Thank you for your reply, I don't link the code to the network, all dimensions are there. I did not make any change before and after the upgrade (from SP0 to SP2.2).
Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor