Habs jetzt hinbekommen.
Weis zwar nicht ob das so "schön" geschrieben ist, aber es funktioniert.
Private Sub CommandButton1_Click()
'Sub ExcelToCatia()
Dim Auswahl As Range
Set Auswahl = Application.InputBox("Zeichnungsnummern auswählen", , , , , , , 8)
Dim CATIA As INFITF.Application
On Error Resume Next
Set CATIA = GetObject("CATIA.application")
If Err.Number <> 0 Then
Set CATIA = CreateObject("CATIA.application")
CATIA.Visble = True
End If
On Error GoTo 0
'active worksheet
Dim oWB As Excel.Workbook
Set oWB = Excel.ActiveWorkbook
Dim oSh As Excel.Worksheet
Set oSh = oWB.ActiveSheet
'create a new product
Dim oProdDoc As ProductDocument
Set oProdDoc = CATIA.Documents.Add("Product")
Dim oRootProd As Product
Set oRootProd = oProdDoc.Product
'rename newly created product to Auswahl
oRootProd.PartNumber = Auswahl(1)
Dim oProductsRoot As Products
Set oProductsRoot = oRootProd.Products
'create new parts named like Auswahl
Dim Anzahl As Integer
Dim i As Integer
Dim newPart As Product
Anzahl = Auswahl.Count
'MsgBox Anzahl
For i = 1 To Anzahl - 1
On Error Resume Next
'MsgBox (Auswahl(i + 1))
Set newPart = oProductsRoot.AddNewComponent("Part", Auswahl(i + 1))
Next i
'Update the product
oRootProd.Update
End Sub
Jetzt will ich nur noch einbauen, dass ausgeblendete Zeilen nicht mit ausgewählt werden.
Dann kann ich schon ganz gut damit arbeiten.
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP