Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Error whil reading file

I try to get the newest .xls file in a directory. Anyone sees why me method
brings up an error and doesnt find the files ? There are files in the ginven
directory.

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Error whil reading file

Code worked OK for me.

--
Regards,
Tom Ogilvy


"Philipp Oberleitner" wrote in message
...
I try to get the newest .xls file in a directory. Anyone sees why me

method
brings up an error and doesnt find the files ? There are files in the

ginven
directory.

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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Error whil reading file

Hmm
dont understand why it brings error


"Tom Ogilvy" schrieb im Newsbeitrag
...
Code worked OK for me.

--
Regards,
Tom Ogilvy


"Philipp Oberleitner" wrote in message
...
I try to get the newest .xls file in a directory. Anyone sees why me

method
brings up an error and doesnt find the files ? There are files in the

ginven
directory.

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






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Error whil reading file

Could it be that the first time through it found the newest--and you didn't keep
track of that first filename?

Option Explicit

Sub Auto_Open()

Dim Dat As Date
Dim DatVgl As Date
Dim Mappe As String
Dim ZMappe As String '<-- added

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

ZMappe = s & "\" & Mappe '<-- added

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

Philipp Oberleitner wrote:

Hmm
dont understand why it brings error

"Tom Ogilvy" schrieb im Newsbeitrag
...
Code worked OK for me.

--
Regards,
Tom Ogilvy


"Philipp Oberleitner" wrote in message
...
I try to get the newest .xls file in a directory. Anyone sees why me

method
brings up an error and doesnt find the files ? There are files in the

ginven
directory.

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





--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
reading from another file and pasting to current file, "combobox" Darius New Users to Excel 1 September 26th 05 07:13 AM
Reading a text file ? WTG Excel Worksheet Functions 2 February 22nd 05 01:29 AM
Reading a text file WTG Excel Discussion (Misc queries) 2 February 22nd 05 01:27 AM
Reading from ini file Tammy[_4_] Excel Programming 4 February 8th 04 10:11 AM
Reading from file Asif[_3_] Excel Programming 4 November 16th 03 05:28 AM


All times are GMT +1. The time now is 10:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"