I found this code - on this site I believe. It's doing the first part of what I need by storing an input box value to a text file. The next part I'm trying to do is have that same text file value populate the input box when I re-open the vbs file - so in effect the last value entered in the input box becomes the default value of the input box.

Dim objFSO 'File System ObjectSet objFSO = CreateObject("Scripting.FileSystemObject")Dim objTS 'Text Stream ObjectConst ForWriting = 2Set objTS = objFSO.OpenTextFile("C:\Users\UserName\Desktop\TextFile.txt", ForWriting, True)objTS.Write(InputBox("Here it is"))objTS.Close()
1

Best Answer


Just swap your Const to read and call the ReadLine method then pass that to your InputBox

Dim objFSO 'File System ObjectSet objFSO = CreateObject("Scripting.FileSystemObject")Dim objTS 'Text Stream ObjectConst ForReading = 1Const ForWriting = 2Set objTS = objFSO.OpenTextFile("C:\Users\UserName\Desktop\TextFile.txt", ForReading)strContent = objTS.ReadLineInputBox(strContent)objTS.Close()