dantheman9
Board Regular
- Joined
- Feb 5, 2011
- Messages
- 175
Hi Im running into issues with vba code using excel 2007 on Windows 7 64bit.
Testing the code on Windows XP it works fine, however when running on Windows 7 doesn't work. (using the DIR function)
Testing the code on Windows XP it works fine, however when running on Windows 7 doesn't work. (using the DIR function)
Code:
Public sFolder As String ' this is a textbox on a userform
Public Sub DetectNewFiles()
' Opens result only (result watcher)
' Const sFolder As String = Fwatcherpath ' folder to watch
Const sFileSpec As String = "*.txt" ' type of file to watch
Const sAgeSelect As String = "00:00:30" ' ignore files newer than this
'Dim sFileName As String
Dim dFileStamp As Date
Dim iFiles As Integer
Dim iNewFiles As Integer
Dim dLastFileProcessed As Date
Dim dLatestFileDetected As Date
myWorkbook.Activate
Dim sh As Worksheet, sPath As String, sName As String
Dim r As Range, Fname As String
Dim ShtName1 As String
Dim ShtName As String
Dim NewSht As Worksheet
Dim str As String
Userform1.Fname1.Caption = LText
Userform1.NFiles.Caption = "Looking in Folder Please wait...."
Application.ScreenUpdating = False
ShtName1 = "FULL RESULTS"
On Error Resume Next
Set sh = Sheets(ShtName1)
On Error GoTo 0
If sh Is Nothing Then
Set NewSht1 = Worksheets.Add
NewSht1.name = ShtName1
Set sh = NewSht1
End If
ShtName = "TEMPS"
On Error Resume Next
Set NewSht = Sheets(ShtName)
On Error GoTo 0
If NewSht Is Nothing Then
Set NewSht = Worksheets.Add
NewSht.name = ShtName
End If
dLastFileProcessed = lastDate
[COLOR=red]sFileName = Dir(sFolder & sFileSpec) ' this bit works fine in XP but not in [/COLOR]
[COLOR=red]' Win 7, the filename is not found
[/COLOR]Do While sFileName <> ""