Sub FileSaveAs(x)
Dim strPath As String
Dim strFileName As String
Dim lngFormat As Long
Dim lngRetVal As Long
Dim nPos As Long
On Error GoTo err_Handler-> Fehler werden hier abgefangen
If x = 1 Then GoTo weiter:
If x = 3 Then GoTo weiter:
spName = ActiveDocument.FormFields(Kundennummer).Result-> spName ist Variable für speichername
If spName = Then MsgBox Ihr Feld Kundennummer zum Speichern ist leer!!!) & vbNewLine & der Speichername heißt jetzt >>Kundenname<<: spName = Name_Vorname
strPath = c:\temp-> Standart Pfad
strFileName = spName
lngFormat = wdFormatdot-> Format wie doc, txt, toc...
If Right$(strPath, 1) <> \ Then -> prüfung für selbsternannten Pfad
strPath = strPath & Application.PathSeparator
End If
With Application.Dialogs(wdDialogFileSaveAs)-> aufruf der Speichermeldungen
.Name = strPath & strFileName
.Format = lngFormat
lngRetVal = .Display
If lngRetVal = -1 Then
strPath = WordBasic.FileNameInfo$(.Name, 5)
strFileName = WordBasic.FileNameInfo$(.Name, 3)
If InStr(1, strFileName, .) > 0 Then-> prüfung des Speichernamens + format
#If VBA6 Then
nPos = InStrRev(strFileName, .)
#Else
nPos = InStrRevVB5(strFileName, .)
#End If
strFileName = Left$(strFileName, nPos - 1)
End If
If Len(strFileName) > 50 Then -> prüfung ob zeichenlänge nicht überschritten
MsgBox Sorry... der Dateiname darf nicht & _
länger als 50 Zeichen sein !, _
vbOKOnly + vbInformation
GoTo exit_Sub
End If
strFileName = strPath & strFileName->speicherroutine
ActiveDocument.SaveAs FileName:=strFileName, _
FileFormat:=lngFormat
If x = 2 Then
GoTo weiter:
End If
Else
MsgBox Du hast grad->Abbrechen' geklickt !, _
vbOKOnlyvbInformation
End If
End With
exit_Sub:
On Error GoTo 0
Exit Sub