So we now have the below script. Debug highlights OpenTextfile as highlighted in bold Before it is put into the second part of the update script can we confirm somehow that the text has been read
Function TextFile_PullData() 'PURPOSE: Send All Data From Text File To A String Variable Dim TextFile As Integer Dim FilePath As String Dim FileContent As String Dim strUser As String
' get the current user name
strUser = CreateObject("WScript.Network").UserName
'or use strUser = CreateObject("WScript.Shell").ExpandEnvironmentStrings("%USERNAME%")
'File Path of Text File
FilePath = "C:\Users\" & strUser & "\Temp\VFile.txt"
'Determine the next file number available for use by the FileOpen function
TextFile = FreeFile
'Open the text file
**Open FilePath For Input As TextFile**
'Store file content inside a variable
FileContent = Input(LOF(TextFile), TextFile)
'Close Text File
Close TextFile
'Report Out Text File Contents
MsgBox FileContent
'have the function return the data to the calling code
TextFile_PullData = FileContent
End Function
Sub UpdateSubject() Dim SaveCode As String Dim KeyWord As String Dim objItem As MailItem
KeyWord = "TSD"
SaveCode = TextFile_PullData
Set objItem = GetCurrentItem()
objItem.Subject = "[" + KeyWord + "=" + SaveCode + "] " + objItem.Subject
End Sub
Function GetCurrentItem() As Object Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
End Select
Set objApp = Nothing
End Function
SaveCode = InputBox(...)withSaveCode = TextFile_PullData? - Ansgar Wiechers