Code:
Sub CATMain()Dim Eingabe As String
EingabeOO = "D:\pf"
EingabeOO = InputBox ("Bitte geben Sie den Öffnungs-ORT ein.", "Alle Parts/Products Öffnen", Eingabe)
Dim oFileSystem As INFITF.FileSystem
Set oFileSystem = CATIA.FileSystem
Dim oFolder As INFITF.Folder
' Verzeichnisname für CATIA-Part
Set oFolder = oFileSystem.GetFolder (EingabeOO)
Dim FileSep As String
FileSep = oFileSystem.FileSeparator
Dim i As Long
Dim j as Variant
Dim oFile As INFITF.File
Dim oActiveDoc As DrawingDocument
For i = 1 To oFolder.Files.Count
Set oFile = oFolder.Files.Item(i)
If Right(oFile.Name, 7) = "CATPart" Then
Set oActiveDoc = CATIA.Documents.Open(oFolder.Path + FileSep + oFile.Name)
On Error Resume Next
Dim document As document
Dim splitname As string
Set document = CATIA.ActiveDocument
splitname = Split(document.Name, ".")
Set pro = document.Product
pro.PartNumber = splitname(0)
oActiveDoc.Save
oActiveDoc.Close
End If
'For i = 1 To oFolder.Files.Count
Set oFile = oFolder.Files.Item(i)
If Right(oFile.Name, 10) = "CATProduct" Then
Set oActiveDoc = CATIA.Documents.Open(oFolder.Path + FileSep + oFile.Name)
'Dim document As document
'Dim splitname As string
Set document = CATIA.ActiveDocument
splitname = Split(document.Name, ".")
Set pro = document.Product
pro.PartNumber = splitname(0)
oActiveDoc.Save
oActiveDoc.Close
End If
Next
End Sub