Dim
strTemplatePath
As
String
Function
SelectTemplate()
As
Boolean
On
Error
GoTo
Err_Handler
Static
strPathStatic
As
String
Dim
dlgOpen
As
FileDialog
Dim
strFile
As
String
Dim
bMode
As
Boolean
Dim
bCancel
As
Boolean
Set
dlgOpen = Application.FileDialog(msoFileDialogOpen)
With
dlgOpen
.AllowMultiSelect =
False
.Filters.Clear
.Filters.Add
"Word-Vorlagen"
,
"*.dotx;*.dotm"
.Filters.Add
"Alle Dateien"
,
"*.*"
.Title =
"Vorlage auswählen"
.InitialFileName = IIf(strPathStatic =
""
, Environ(
"UserProfile"
), strPathStatic)
.Show
bMode =
True
strFile = .SelectedItems(1)
bMode =
False
If
bCancel
Then
SelectTemplate =
False
Else
strTemplatePath = strFile
SelectTemplate =
True
strPathStatic = strTemplatePath
End
If
End
With
Err_Exit:
Exit
Function
Err_Handler:
If
bMode =
True
Then
Err.Clear
bCancel =
True
Resume
Next
Else
MsgBox Err.Description, vbCritical,
"Fehler"
Resume
Err_Exit
End
If
End
Function
Private
Sub
cmdCancel_Click()
Unload
Me
End
Sub
Private
Sub
cmdOK_Click()
Unload
Me
End
Sub
Private
Sub
cmdPDFPath_Click()
Dim
iResult
As
Integer
With
Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName =
Me
.txtPDFPath.Value
iResult = .Show
If
iResult <> 0
Then
Me
.txtPDFPath.Value = .SelectedItems(1)
End
If
End
With
End
Sub
Private
Sub
cmdTemplate_Click()
strTemplatePath =
Me
.txtTemplate.Value
If
SelectTemplate =
True
Then
Me
.txtTemplate.Value = strTemplatePath
End
If
End
Sub