I am learning VBA with CATIA scripting(macros). My code looks like this
Sub CATMain()
Dim oPart1 As Document
Set oPart1 = CATIA.ActiveDocument
Dim currentWindow As Windows 'I am getting an error here
Set currentWindow = CATIA.Windows
Dim openWind As Integer
openWind = currentWindow.Count
End Sub
I get this kind of errors with other collections too, some of them work whenever I make a new project library, but this one is not going away
I have tried to find an answer on many forums and even here we have some similar topics, but I didn't get an answer to my issue
Perhaps you have another "Windows" object type in your references which is making the definition ambiguous.
Try this:
Dim wx as INFITF.Windows
Personally I normally don't bother with defining variables for the collection properties. For example I would just use "CATIA.Windows" whenever I needed to reference the collection of windows.
Also, if you have multiple versions of CATIA installed, or have uninstalled a version lately, it is possible the the incorrect version of the libraries are registered. This will cause errors like you are seeing.
So if you have multiple versions (or have uninstalled recently) Run "CNext.exe -regserver" from the exe folder of the version you want to use.