Hi,
I have set up a little program where you can browse to a specific file and the file and pathname are displayed in the textbox "txtFile".
I then would like a textbox where the "date modified" of that particular file (from Windows Explorer) is displayed by clicking on a button called "cmdFiledate".
I have the following code on the On_Click Event of button "cmdFiledate":
Private Sub cmdFileDate_Click()
'Code adapted from
'Microsoft Knowledge Base Article - 186118
'HOWTO: Use FileSystemObject with Visual Basic
'http://support.microsoft.com/default.aspx?scid=kb;en-us;186118
If CheckChoice(True) Then
Exit Sub
End If
Dim myFileSystem As New FileSystemObject
Dim myFile As File
FilePath = Me.txtFile
Set myFile = myFileSystem.GetOpenFileName(txtFile)
MsgBox "Date Last Modified : " & myFile.DateLastModified & vbNewLine
Set myFile = Nothing
Set myFileSystem = Nothing
End Sub
It keeps getting stuck on the line:
Dim myFileSystem As New FileSystemObject
Also, the way that code was run was that the file path was displayed in one text box, and the actual file name was stored in a list box. I have the file name and pathname displayed in only a textbox (txtFile).
Does anyone know what is wrong with the code?
Thanks,
Binger
I have set up a little program where you can browse to a specific file and the file and pathname are displayed in the textbox "txtFile".
I then would like a textbox where the "date modified" of that particular file (from Windows Explorer) is displayed by clicking on a button called "cmdFiledate".
I have the following code on the On_Click Event of button "cmdFiledate":
Private Sub cmdFileDate_Click()
'Code adapted from
'Microsoft Knowledge Base Article - 186118
'HOWTO: Use FileSystemObject with Visual Basic
'http://support.microsoft.com/default.aspx?scid=kb;en-us;186118
If CheckChoice(True) Then
Exit Sub
End If
Dim myFileSystem As New FileSystemObject
Dim myFile As File
FilePath = Me.txtFile
Set myFile = myFileSystem.GetOpenFileName(txtFile)
MsgBox "Date Last Modified : " & myFile.DateLastModified & vbNewLine
Set myFile = Nothing
Set myFileSystem = Nothing
End Sub
It keeps getting stuck on the line:
Dim myFileSystem As New FileSystemObject
Also, the way that code was run was that the file path was displayed in one text box, and the actual file name was stored in a list box. I have the file name and pathname displayed in only a textbox (txtFile).
Does anyone know what is wrong with the code?
Thanks,
Binger