RawlinsCross
Active Member
- Joined
- Sep 9, 2016
- Messages
- 402
Hi... I'm almost there after my online searches into this issue. Basically my title says it all... here's the code. It launches notepad but it is all gibberish.
Sub OpenEmail()
Dim FileSys As FileSystemObject
Dim objFile As File
Dim myFolder
Dim strFilename As String
Dim dteFile As Date
'set path for files - change for your folder
Const myDir As String = "c:\Users\jhalfyard\Documents\Emails"
'set up filesys objects
Set FileSys = New FileSystemObject
Set myFolder = FileSys.GetFolder(myDir)
'loop through each file and get date last modified. If largest date then store Filename
dteFile = DateSerial(1900, 1, 1)
For Each objFile In myFolder.Files
If objFile.DateLastModified > dteFile Then
dteFile = objFile.DateLastModified
strFilename = objFile.Name
End If
Next objFile
'This part works but characters in notepad page is just giberish
'Plus it only launches in the background
'(i.e. you have to click it on the taskbar)
ChDir "C:\Users\jhalfyard\Documents\Emails"
Shell "Notepad " & strFilename
Set FileSys = Nothing
Set myFolder = Nothing
End Sub
Sub OpenEmail()
Dim FileSys As FileSystemObject
Dim objFile As File
Dim myFolder
Dim strFilename As String
Dim dteFile As Date
'set path for files - change for your folder
Const myDir As String = "c:\Users\jhalfyard\Documents\Emails"
'set up filesys objects
Set FileSys = New FileSystemObject
Set myFolder = FileSys.GetFolder(myDir)
'loop through each file and get date last modified. If largest date then store Filename
dteFile = DateSerial(1900, 1, 1)
For Each objFile In myFolder.Files
If objFile.DateLastModified > dteFile Then
dteFile = objFile.DateLastModified
strFilename = objFile.Name
End If
Next objFile
'This part works but characters in notepad page is just giberish
'Plus it only launches in the background
'(i.e. you have to click it on the taskbar)
ChDir "C:\Users\jhalfyard\Documents\Emails"
Shell "Notepad " & strFilename
Set FileSys = Nothing
Set myFolder = Nothing
End Sub