marcvanderpeet12
Member
Dear all,
I got the following VBA code whick opens a folders, checks whether a file is there and then export an excel file from access in the map. All works fine except that the macro does not work if there's no file in the map.
Does anybody know how I can enhance code below so it
- checks whether there is a file
if yes - delete and execute rest
if no - just execute macro
Public Function ExportDashboardExcel()
Kill "X:\SSC_HR\SENS\Bedrijfsbureau\Rapportages\sterren\MAANDELIJKSE RAPPORTAGES\UITDRAAI DB_MAANDELIJKS_DASHBOARD\*.xls"
MsgBox ("De bestanden zijn gedelete")
Const FILE_PATH As String = "X:\SSC_HR\SENS\Bedrijfsbureau\Rapportages\Sterren\MAANDELIJKSE RAPPORTAGES\UITDRAAI DB_MAANDELIJKS_DASHBOARD\"
Dim FullPath As String
Dim bestandsnaam As String
Dim datum As String, tijdstempel As String
strFullPath = FILE_PATH
datum = Date
tijdstempel = Format(datum, "d-m-yyyy")
bestandsnaam = "Dashboard " & tijdstempel & ".xls"
DoCmd.TransferSpreadsheet acExport, , "Dashboard", strFullPath & bestandsnaam, False
MsgBox ("De bestanden staan er")
End Function
I got the following VBA code whick opens a folders, checks whether a file is there and then export an excel file from access in the map. All works fine except that the macro does not work if there's no file in the map.
Does anybody know how I can enhance code below so it
- checks whether there is a file
if yes - delete and execute rest
if no - just execute macro
Public Function ExportDashboardExcel()
Kill "X:\SSC_HR\SENS\Bedrijfsbureau\Rapportages\sterren\MAANDELIJKSE RAPPORTAGES\UITDRAAI DB_MAANDELIJKS_DASHBOARD\*.xls"
MsgBox ("De bestanden zijn gedelete")
Const FILE_PATH As String = "X:\SSC_HR\SENS\Bedrijfsbureau\Rapportages\Sterren\MAANDELIJKSE RAPPORTAGES\UITDRAAI DB_MAANDELIJKS_DASHBOARD\"
Dim FullPath As String
Dim bestandsnaam As String
Dim datum As String, tijdstempel As String
strFullPath = FILE_PATH
datum = Date
tijdstempel = Format(datum, "d-m-yyyy")
bestandsnaam = "Dashboard " & tijdstempel & ".xls"
DoCmd.TransferSpreadsheet acExport, , "Dashboard", strFullPath & bestandsnaam, False
MsgBox ("De bestanden staan er")
End Function