Vielen Dank Bernd,
Dein Code funktioniert einwandfrei, Ich glaube ich habe vorher mit "For-Next" einen Fehler gemacht.( Ich bin halt noch ein Anfänger)
Ich schicke mal den ganzen code hier, Falls jemand es braucht.
Sub CATMain()
'Erstellung eines CADProduktes
Dim ADoc As Document
Set ADoc = CATIA.Documents.Add("Product")
'Umbenennen
Dim BV As ProductDocument
Set BV = CATIA.ActiveDocument
Dim Product1 As Product
Set Product1 = BV.Product
Product1.PartNumber = "BauteilVergleich"
'Fenster Zahl n ohne das Fenster "BauteilVergleich"
Dim FensterZahl As Integer
Dim n As Integer
FensterZahl = CATIA.windows.Count
n = FensterZahl - 1
Dim windows As windows
Set windows = CATIA.windows
windows.Item(n + 1).Activate
Dim oRootDocument As ProductDocument
Set oRootDocument = CATIA.ActiveDocument
'Zusammengügen von geöffneten Fenster
For i = 1 To n
windows.Item(i).Activate
Set oDocument = CATIA.ActiveDocument
If TypeName(oDocument) = "PartDocument" Or TypeName(oDocument) = "ProductDocument" Then
Set oChildProduct = oDocument.Product
oRootDocument.Product.Products.AddComponent oChildProduct
End If
Next
End Sub
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP