Sub CATMain()
'_____________Eingabe des Speicherord_________________________________________________

Dim Eingabe As String
Strich    = "\"
Eingabe = "D:\Pf"
Eingabe = InputBox ("Bitte geben Sie Speicher Ort  ein.", "Eingabe Speichern", Eingabe)
'__________________________________________________________________________________

'_____________Abfrage Selektierte Elemente_____________________________________________

'Dim UserSelektion As Selection
' Set UserSelektion = productDocument1.Selection


Dim UserSelektion As Selection
Set productDocument1 = CATIA.ActiveDocument    
    Set UserSelektion = productDocument1.Selection    
    UserSelektion.Search "(CATAsmSearch.Part+(CATAsmSearch.Product)),all"


'Dim UserSelektion As Selection
'Set  UserSelektion = CATIA.ActiveDocument.Selection

'If UserSelektion.Count > 0 Then

For I = 1 to UserSelektion.Count 
'MsgBox(UserSelektion.Item(I).Value.Name)
Name = (UserSelektion.Item(I).Value.ReferenceProduct.Name)    'Name = (UserSelektion.Item(I).Value.Name)  'product1.PartNumber
'__________________________________________________________________________________

'_____________Zuordnung____________________________________________________________

VAR_pfad = Eingabe
Set productDocument1 = CATIA.ActiveDocument
'Set Name = UserSelektion productDocument1.Product
Datei = VAR_pfad & Strich & Name
'__________________________________________________________________________________

'_____________Speicher Befehl Aktiver Fenster___________________________________________

'CATIA.ActiveDocument.SaveAs Datei
'__________________________________________________________________________________


'_____________Abfrage Selektierte Elemente zum Speichen_________________________________

Dim SelectedProduct As Product
Set SelectedProduct = CATIA.ActiveDocument.Selection.Item2(I).Value
Dim doc As Document
Set doc = SelectedProduct.ReferenceProduct.Parent
'__________________________________________________________________________________

'_____________Speicher Befehl Selektierte Elemente ______________________________________

CATIA.DisplayFileAlerts = False
'If TypeName(doc) = PartDocument then doc.SaveAs Datei
doc.SaveAs Datei
'__________________________________________________________________________________

'_____________Informations Speicherbox______________________________________

'Dim Box, Speicher As Long

'MsgBox "Das Dokument wird gespeichert:" & Chr (13) & Chr (10) & VAR_pfad & Strich & Name & "",64, "GESPEICHERT"
'__________________________________________________________________________________
Next
End Sub


