Probier es mal hiermit:
For Each fil In fc
t = fil.Type
If (t = "CATIA Drawing" or t = "CDD-Datei") then
filename = fil.Name
Pos1 = instr(1, s, filename)
If Pos1 = 0 Then
Set documents1 = CATIA.Documents
PFADEINGABE = fld & "\" & fil.name
scount = scount + 1
sfiles = scount & ". " & filename & "<p>" & sfiles
Set document1 = documents1.Open(PFADEINGABE)
CATIA.ActiveWindow.WindowState = 0
Set drawingDocument1 = CATIA.ActiveDocument
If t = "CATIA Drawing" then
fileoutname = replace(fil.name,".CATDrawing","")
End If
If t = "CDD-Datei" then
fileoutname = replace(fil.name,".cdd","")
End If
If folderoutput = "NEIN" then
PFADAUSGABE = fld & "\" & fileoutname & ".pdf"
Else
PFADAUSGABE = fldo & "\" & fileoutname & ".pdf"
End If
On Error Resume Next
drawingDocument1.ExportData PFADAUSGABE, "pdf"
drawingDocument1.Close
If Err <> 0 Then
s = s & PFADEINGABE & "; " & "Fehler!"
Else
s = s & PFADEINGABE & "; " & PFADAUSGABE
End If
s = s & vbCrLf
End if
End if
Next
For Each sfld In fld.SubFolders
Set fc = sfld.Files
For Each fil In fc
t = fil.Type
If (t = "CATIA Drawing" or t = "CDD-Datei") then
filename = fil.Name
Pos1 = instr(1, s, filename)
If Pos1 = 0 Then
Set documents1 = CATIA.Documents
PFADEINGABE = sfld & "\" & fil.name
scount = scount + 1
sfiles = scount & ". " & filename & "<p>" & sfiles
Set document1 = documents1.Open(PFADEINGABE)
CATIA.ActiveWindow.WindowState = 0
Set drawingDocument1 = CATIA.ActiveDocument
If t = "CATIA Drawing" then
fileoutname = replace(fil.name,".CATDrawing","")
End If
If t = "CDD-Datei" then
fileoutname = replace(fil.name,".cdd","")
End If
If folderoutput = "NEIN" then
PFADAUSGABE = sfld & "\" & fileoutname & ".pdf"
Else
PFADAUSGABE = fldo & "\" & fileoutname & ".pdf"
End If
On Error Resume Next
drawingDocument1.ExportData PFADAUSGABE, "pdf"
drawingDocument1.Close
If Err <> 0 Then
s = s & PFADEINGABE & "; " & "Fehler!"
Else
s = s & PFADEINGABE & "; " & PFADAUSGABE
End If
s = s & vbCrLf
End if
End if
Next
For Each ssfld In sfld.SubFolders
Set fc = ssfld.Files
For Each fil In fc
t = fil.Type
If (t = "CATIA Drawing" or t = "CDD-Datei") then
filename = fil.Name
Pos1 = instr(1, s, filename)
If Pos1 = 0 Then
Set documents1 = CATIA.Documents
PFADEINGABE = ssfld & "\" & fil.name
scount = scount + 1
sfiles = scount & ". " & filename & "<p>" & sfiles
Set document1 = documents1.Open(PFADEINGABE)
CATIA.ActiveWindow.WindowState = 0
Set drawingDocument1 = CATIA.ActiveDocument
If t = "CATIA Drawing" then
fileoutname = replace(fil.name,".CATDrawing","")
End If
If t = "CDD-Datei" then
fileoutname = replace(fil.name,".cdd","")
End If
If folderoutput = "NEIN" then
PFADAUSGABE = ssfld & "\" & fileoutname & ".pdf"
Else
PFADAUSGABE = fldo & "\" & fileoutname & ".pdf"
End If
On Error Resume Next
drawingDocument1.ExportData PFADAUSGABE, "pdf"
drawingDocument1.Close
If Err <> 0 Then
s = s & PFADEINGABE & "; " & "Fehler!"
Else
s = s & PFADEINGABE & "; " & PFADAUSGABE
End If
s = s & vbCrLf
End if
End if
Next
For Each sssfld In ssfld.SubFolders
Set fc = sssfld.Files
For Each fil In fc
t = fil.Type
If (t = "CATIA Drawing" or t = "CDD-Datei") then
filename = fil.Name
Pos1 = instr(1, s, filename)
If Pos1 = 0 Then
Set documents1 = CATIA.Documents
PFADEINGABE = sssfld & "\" & fil.name
scount = scount + 1
sfiles = scount & ". " & filename & "<p>" & sfiles
Set document1 = documents1.Open(PFADEINGABE)
CATIA.ActiveWindow.WindowState = 0
Set drawingDocument1 = CATIA.ActiveDocument
If t = "CATIA Drawing" then
fileoutname = replace(fil.name,".CATDrawing","")
End If
If t = "CDD-Datei" then
fileoutname = replace(fil.name,".cdd","")
End If
If folderoutput = "NEIN" then
PFADAUSGABE = sssfld & "\" & fileoutname & ".pdf"
Else
PFADAUSGABE = fldo & "\" & fileoutname & ".pdf"
End If
On Error Resume Next
drawingDocument1.ExportData PFADAUSGABE, "pdf"
drawingDocument1.Close
If Err <> 0 Then
s = s & PFADEINGABE & "; " & "Fehler!"
Else
s = s & PFADEINGABE & "; " & PFADAUSGABE
End If
s = s & vbCrLf
End if
End if
Next
For Each ssssfld In sssfld.SubFolders
Set fc = ssssfld.Files
For Each fil In fc
t = fil.Type
If (t = "CATIA Drawing" or t = "CDD-Datei") then
filename = fil.Name
Pos1 = instr(1, s, filename)
If Pos1 = 0 Then
Set documents1 = CATIA.Documents
PFADEINGABE = ssssfld & "\" & fil.name
scount = scount + 1
sfiles = scount & ". " & filename & "<p>" & sfiles
Set document1 = documents1.Open(PFADEINGABE)
CATIA.ActiveWindow.WindowState = 0
Set drawingDocument1 = CATIA.ActiveDocument
If t = "CATIA Drawing" then
fileoutname = replace(fil.name,".CATDrawing","")
End If
If t = "CDD-Datei" then
fileoutname = replace(fil.name,".cdd","")
End If
If folderoutput = "NEIN" then
PFADAUSGABE = ssssfld & "\" & fileoutname & ".pdf"
Else
PFADAUSGABE = fldo & "\" & fileoutname & ".pdf"
End If
On Error Resume Next
drawingDocument1.ExportData PFADAUSGABE, "pdf"
drawingDocument1.Close
If Err <> 0 Then
s = s & PFADEINGABE & "; " & "Fehler!"
Else
s = s & PFADEINGABE & "; " & PFADAUSGABE
End If
s = s & vbCrLf
End if
End if
Next
Next
Next
Next
Next
' FileSystemObject objFs oeffnen
Set objFs= CreateObject("Scripting.FileSystemObject")
If folderoutput = "NEIN" then
strDateiname = folderinput + "\" + "Drawing2PDF-DeepStructure-Report.csv"
Else
strDateiname = folderoutput + "\" + "Drawing2PDF-DeepStructure-Report.csv"
End If
Set objTextStream = objFs.CreateTextFile(strDateiname, True)
strWriteString = s
objTextStream.Write strWriteString
objTextStream.Close
Set objTextStream = Nothing
Set objFs = Nothing
MsgBox "Fertig !" & vbCrLf & "Eine Logdatei finden Sie hier: " & strDateiname
Mit diesem (unvollständigen) Script werden bis zu vier Unterverzeichnisebenen mitdurchsucht und die CATDrawings als PDF gespeichert.
Die Logvariable s enthält alle Dateinamen. Diese Logdaten werden in die Datei Drawing2PDF-DeepStructure-Report.csv geschrieben.
Maximilianus
------------------
Maximilianus
Dipl.-Ing. (Wi-Ing ET)
PLM-Consultant
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP