Option
Explicit
Public
Sub
Button_Click()
Dim
wbkBook
As
Workbook
Dim
strPath
As
String
, strFileExtension
As
String
, strFileName
As
String
Dim
lngButtonRow
As
Long
strPath = "C:\Auswertung\"
strFileExtension =
".xlsx"
lngButtonRow = ActiveSheet.Buttons(Application.Caller).TopLeftCell.Row
strFileName = Cells(lngButtonRow, 1).Value & strFileExtension
If
Dir$(PathName:=strPath & strFileName, Attributes:=vbNormal) <>
""
Then
On
Error
Resume
Next
Set
wbkBook = Workbooks(strFileName)
On
Error
GoTo
0
If
wbkBook
Is
Nothing
Then
Call
Workbooks.Open(Filename:=strPath & strFileName)
Else
Call
MsgBox(
"Die Mappe "
& wbkBook.Name &
" ist bereits geöffnet..."
, vbExclamation)
Set
wbkBook =
Nothing
End
If
Else
Call
Workbooks.Add.SaveAs(Filename:=strPath & strFileName, FileFormat:=xlOpenXMLWorkbook)
End
If
End
Sub