0

I have a piece of VBA code (copied from Emmett Ross' as below). It works well in CATIA VBA, but did not in Excel VBA (to work with CATIA from Excel VBA). The error "Type Mismatch" pointed in the line "Set parameters1 = part1.Parameters". All the needed references was checked already. Can anyone explain this to me about this?

'Active document is a single part file Dim partDocument1 As Document Set partDocument1 = CATIA.ActiveDocument

Dim part1 As Part Set part1 = partDocument1.Part

Dim parameters1 As Parameters
Set parameters1 = part1.Parameters 

'create a new length type parameter, set its value to 0 for now
Dim length1 As Dimension
Set length1 = parameters1.CreateDimension("", "LENGTH", 0#)
braX
  • 11,506
  • 5
  • 20
  • 33
  • I guess excel does also have a parameter object. Try do add the library on the dimensioning of the variable (e.g. _Dim parameters1 as KnowledgewareTypeLib.Parameters_). – Shrotter Sep 28 '22 at 10:59
  • Yeah! I fixed my problem successfully thanks to your help. Thanks a lot! – Hung Pham Vu Sep 28 '22 at 18:33

1 Answers1

0

This error may be caused by Excel VBA not importing the CATIA DLL library

You should omit the Dim declaration

Set parameters1 = part1.Parameters 
Set length1 = parameters1.CreateDimension("", "LENGTH", 0#)