Hello Rick,
I've tried everything I can think of with the code you provided to me, but I still end up with a Runtime Error (9) Subcript out of range. I thought it was because it wasn't finding the string Guest Information, but I changed the text file so it would find it and it still blows up on that statement.
Here is the code that you had me try:
Code:
Sub GetEmailInfo()
Dim X As Long, FilePathAndName As String, TotalFile As String, FileNum As Long, Arr() As String
Dim ReportDate As String, ReportNumber As String, StoreNumber As String, Issue As String
' Get path and filename by whatever means you do now
FilePathAndName = "c:\temp\Email Text.txt"
' Read entire file into TotalFile variable
FileNum = FreeFile
Open FilePathAndName For Binary As #FileNum
TotalFile = Space(LOF(FileNum))
Get #FileNum, , TotalFile
Close #FileNum
' Get Report Number
Arr = Split(TotalFile, "REPORT #: ")
ReportNumber = Val(Arr(1))
' Get Report Date
Arr = Split(TotalFile, "REPORTED: ")
ReportDate = Split(Arr(1), vbCrLf)(0)
' Get Store Number
Arr = Split(TotalFile, vbCrLf & "Store ")
StoreNumber = Val(Arr(1))
' Get Issue
Arr = Split(TotalFile, "ADDITIONAL COMMENTS:")
Arr = Split(Arr(1), vbCrLf, 3)
Arr = Split(Arr(2), vbCrLf & vbCrLf)
Issue = Arr(0)
' Let's see what we got
MsgBox "Report #: " & ReportNumber & vbLf & vbLf & _
"Report Date: " & ReportDate & vbLf & vbLf & _
"Stort #: " & StoreNumber & vbLf & vbLf & _
"Issue: " & Issue
End Sub
I'm not sure if you got the email samples that I emailed to you or not? I'm currently cut/pasting 200+ emails a day in Excel. There must be a faster way of doing this?
Any help you can give me would be greatly appreciated.
bcloring (Bob Loring) bcloring@gmail.com
Bookmarks