Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
stPath = "C:\Documents and Settings\Fredrick\My Documents\timesheet access programs\fox-otfolder\ACCESS ROUTINES FOR VISUAL BASIC\ea.doc"
If Dir(stPath)<>"" Then
FollowHyperlink stPath
Else
MsgBox "Cannot find " & strpath
End If
Sub BuildDocTable(strPath)
'References Office 9.0 Object Library
'Fields in tblDocumentListing:
'DocID: Autonumber
'FileFullPath: Text, 255
'CrDate: Date
'AcDate: Date
'ModDate: Date
'FileSize: Long Integer
Dim lngFileIndex As Long
Dim vFile
Dim vFilePath
Dim vDateCreated
Dim vDateLastAccessed
Dim vDateLastModified
Dim vFileSize As Long
Dim strSQL As String
Dim vMaxFileSize As Long
Dim vMaxPathLen As Integer
Dim fs
If Right(strPath, 1) <> "\" Then
strPath = strPath & "\"
End If
'File system object to get file details
Set fs = CreateObject("Scripting.FileSystemObject")
vMaxFileSize = 2147483647 '2,147,483,647, max of long
vMaxPathLen = 255 'max of text
'Look for Word documents in strPath
With Application.FileSearch
.NewSearch
.LookIn = strPath
.SearchSubFolders = True
.FileType = msoFileTypeWordDocuments
.FileName = "*.doc"
.MatchTextExactly = True
'If files are found ...
If .Execute() > 0 Then
'Get the details
For lngFileIndex = 1 To .FoundFiles.Count
vFilePath = .FoundFiles(lngFileIndex)
Set vFile = fs.GetFile(.FoundFiles(lngFileIndex))
vDateCreated = vFile.DateCreated
vDateLastAccessed = vFile.DateLastAccessed
vDateLastModified = vFile.DateLastModified
vFileSize = FileLen(.FoundFiles(lngFileIndex))
Set vFile = Nothing
'If there is a problem, ...
If Len(vFilePath) > vMaxPathLen Or vFileSize > vMaxFileSize Then
Debug.Print vFilePath
Else
'Otherwise insert details into tblDocumentListing
'Uncomment the next line, and its match below,
'to get rid of "You are about To ..." warning
'message.
'DoCmd.SetWarnings False
strSQL = "INSERT INTO tblDocumentListing " _
& "( FileFullPath, CrDate, AcDate, ModDate, FileSize ) " _
& "SELECT '" & vFilePath & "'," _
& MakeUSDate(vDateCreated) & "," _
& MakeUSDate(vDateLastAccessed) & "," _
& MakeUSDate(vDateLastModified) & "," _
& vFileSize
End If
'Uncomment the two SetWarnings to get rid of
'"You are about To ..." warning message.
'DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
'DoCmd.SetWarnings True
'Next file
Next lngFileIndex
End If
End With
End Sub
Function MakeUSDateX(X As Variant)
'Needed for SQL
If Not IsDate(X) Then Exit Function
MakeUSDate = "#" & Month(X) & "/" & Day(X) & "/" & Year(X) & "#"
End Function