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
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