Search code examples
vbavbscriptcatia

CATIA VBA Enable use of "Scripting.Dictionary" in .CATScript


When running a .CATScript whose code was copied from the VBA environment and functions as intended when run in the VBA environment I get the following error:

The scripting engine has reported the following error:

Source: Microsoft VBScript runtime error

Description: Variable is undefined: 'Scripting'

Line: 9

Column: 4

How can I have this script use the "Microsoft Scripting Runtime" reference library?


Solution

  • I've searched on google for a bit and I believe the following would solve my problem:

    'in original VBA code:
    Dim dict As Scripting.Dictionary
    Set dict = New Scripting.Dictionary
    
    'To have this work in .CATScript, replace the code above with:
    Dim dict
    Set dict = CreateObject _
    ("Scripting.Dictionary")