PDA

View Full Version : [SOLVED:] Run time error 91



angiepeters
05-11-2005, 08:11 AM
I am trying to write code that will set parameters in Catia (a 3d modelling program) to values I have in excel. when I run it I get Run-time error 91 'Object variable or with block variable not set' and highlites the line 'set windowasm....'
I am new at this stuff and can't figure out what I am doing wrong.
Hope someone can help me!


Dim CATDocs As Documents
Dim specsAndGeomWindow1 As Window
Dim base As Document
Dim jaw As Document
Dim windowasm As ProductDocument
Dim windowprod As Product
Dim parameterslist As Parameters
Dim viewer3D1 As Viewer

Private Sub CommandButton1_Click()
Dim catia As Object
On Error Resume Next
Set catia = GetObject(, "CATIA.Application")
If Err.Number = 425 Then
Set catia = CreateObject("CATIA.Application")
Err.Clear
End If
On Error GoTo 0
osmwidth = Sheet1.Cells(12, 4).Value
osmheight = Sheet1.Cells(14, 4).Value
osmradius = Sheet1.Cells(20, 4).Value
Set windowasm = catia.Documents.Open("C:\Documents and Settings\Administrator\My Documents\skeleton\CTC3\Product1.CATProduct") :dunno
Set windowprod = windowasm.Product
Set parameterList = windowprod.Parameters
Set OverallWidth = parameterList.Item("Overall Width")
OverallWidth.Value = osmwidth
Set OverallHeight = parameterList.Item("Overall Height")
OverallHeight.Value = osmheight
Set RadLeg = parameterList.Item("Camber (leg/rad)")
RadLeg.Value = osmradius
windowprod.Update
Set SpecsAndGeomWindow = catia.ActiveWindow
Set viewer3D1 = SpecsAndGeomWindow.ActiveViewer
viewer3D1.Reframe
End Sub

Bob Phillips
05-11-2005, 08:19 AM
Presumably this product supports automation? Assuming so, have you set a reference to its type library (Tools>References)?

angiepeters
05-11-2005, 08:30 AM
I have set a reference yes. Are there any other settings I might need to change?

Zack Barresse
05-11-2005, 09:25 AM
angipeters - some info 4 u I took the liberty of editing your post with them, hope you don't mind. :)

angiepeters
05-11-2005, 09:27 AM
Not at all. Thanks!

angiepeters
05-13-2005, 11:28 AM
I figured out the problem. Turns out, it was a registration issue with the 3d modelling program. Once that was resolved, it ran fine.
Thanks for your help though!

Angie