Code:
Sub CATMain()
Dim Eingabe As String
'sInputFile = CATIA.FileSelectionBox("*.CATProduct auswaehlen und ab geht's! (alle Produkte und Parts werden in diesem Ordner geoeffnet und mit dem Dateinamen abgeglichen)", "*.CATProduct", 'CatFileSelectionModeOpen)'EingabeOO = Left(sInputFile, InStrRev(sInputFile, "\") )
EingabeOO = "D:\Beispiel"
EingabeOO = InputBox ("Bitte geben Sie den Oeffnungs Ort ein.", "Alle Parts/Products Oeffnen", 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
'Dim BackView As DrawingView
'Dim oText As DrawingText
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)
'------------------------------- hier Code wenn noetig ------------------------------------
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
'------------------------------- hier Code wenn noetig ------------------------------------
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)
'------------------------------- hier Code wenn noetig ------------------------------------
'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
'------------------------------- hier Code wenn noetig ------------------------------------
End If
Next
End Sub