Problems with reading files

  • Thread starter Philipp Oberleitner
  • Start date
P

Philipp Oberleitner

Hmm i wrote a makro that should search the newest .xls file in a directory
and open it. But it alway brings errors and no file gets opened. Can anyone
help me ?

Public ZMappe As String

Sub Auto_Open()

Dim Dat As Date
Dim DatVgl As Date
Dim Mappe As String

Const s = _
"F:\Siemens"
Mappe = Dir(s & "\*.xls")
Dat = FileDateTime(s & "\" & Mappe)

Do Until Mappe = ""
DatVgl = FileDateTime(s & "\" & Mappe)
If DatVgl > Dat Then
Dat = DatVgl
ZMappe = s & "\" & Mappe
End If
Mappe = Dir()
Loop

Workbooks.Open Filename:=ZMappe



End Sub

Thanks alot in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top