Access Script not working in Access 2007 on Windows 7 64
Posted on 2011-09-06
Greetings, I have a snippet of code that I wrote a while ago that looks at a directory and returns the folder contents into a temporary table, it's worked just fine until the new Windows 7 64 workstations try to run the code, now it's only returning the helpdesk.nal file that's on each users desktop. Any help would be appreciated, script follows:
Private Sub cmd_inactive_Click()
Me.tgl_dwg = -1
'Start the Progress Meter
Me.ProgressBar6.Visible = True
Dim zzz As String
Dim aaa As String
Dim yyy As Integer
' Flag for canceled Dialog
Dim bCanceled As Boolean
Dim fDialog As Office.FileDialog
Dim varFile As Variant
Dim strPath As String
'Clear listbox contents.
Me.filelist.RowSource = ""
‘Clear the canceled flag
bCanceld = False
' Changed Type to Folder Dialog
'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
' Multiple disabled
'Allow user to make multiple selections in dialog box.
.AllowMultiSelect = False
' Dialog box retitled to specify directory.
'Set the title of the dialog box.
.Title = "Please select the active directory"
'Clear out the current filters, and add our own.
' Filters Disabled
'.Filters.Add "All Files", "*.*"
' Differentiation between Open and Cancel only
'Show the dialog box. If the .Show method returns True, the
'user picked at least one file. If the .Show method returns
'False, the user clicked Cancel.
If .Show = -1 Then
' File selection removed
'Loop through each file selected and add it to the list box.
'For Each vrtSelectedItem In .SelectedItems
' Me.filelist.AddItem vrtSelectedItem
' Return the Chosen directory
strPath = fDialog.InitialFileName
MsgBox "You clicked Cancel in the folder dialog box."
bCanceled = True
If bCanceled = False Then
' Table clear to allow cancel
'first clear out temp table
Me.ProgressBar6.Value = 1
' Open the text file for filenames
Open "C:\DCN\OUTPUT.txt" For Output As #1
' Use the DIR() function to get the first filename
Dim strFile As String
strFile = Dir(strPath & "*.*")
' Loop and get the next file in directory
' Output to textfile
Do While Len(strFile) > 0
Print #1, strFile
strFile = Dir()
Me.ProgressBar6.Value = 2
'Run a timer for 10 seconds to allow dir to finish
Dim PauseTime, Start, Finish, TotalTime
PauseTime = 10 ' Set duration.
yyy = 3
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
If yyy < 4500 Then
Me.ProgressBar6.Value = yyy
yyy = yyy + 1
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
End If ' canceled
Me.tgl_dwg = -1
Me.ProgressBar6.Visible = False
Me.holder = 19 + Len(Me.activesearch)