View Single Post
 
Old 04-02-2020, 12:04 PM
marceepoo marceepoo is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Sep 2012
Posts: 22
marceepoo is on a distinguished road
Default Is it possible to use a .txt file to populate a msgbox prompt field

I get a call stack error when I try to use the following code to populate a msgbox prompt field:
Quote:
Dim TextFile As Integer
Dim FilePath As String
Dim FileContent As String

'File Path of Text File
FilePath = sFullname ' "E:\Zmani\Logging\202004011500__Tmp_61385499383529 09.py_.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
The following is the text inside the file ["202004011500__Tmp_6138549938352909.py_.txt"] I'm trying to use as data to populate the Msgbox prompt field:

Quote:
1. Check the "Name of Bookmark" and "Exhibit No." fields below to make sure that the data in those fields is correct.
2. If the data in those fields is correct: Push the light blue colored button (in the lower right hand corner of the form) entitled "Insert Bookmark Where the Cursor is Situated".
3. But if the data in those fields is NOT correct:
[A] Move your cursor to the paragraph (in the Table of Exhibits) to which you want to make a cross-reference; and then ...
[B] Push the light green "Update Fields" button.
NB: Pushing that button will update the fields, and return your cursor to the place where it was when you pushed the "Update Fields" button.

This form will remain open until you close it, in order to make it possible for you to manually populate as many field as you want, by going to paragraphs in the Table of Exhibits and then clicking the "Update Fields" button.
I would prefer to populate my Error messages in my programs with uniform text that I could easily save in text files or rtf or doc or docx or html, etc files, instead of having to code the messages in vba, line by line, etc., e.g.:

"ERROR Message from Module " & chr(34) & strModuleName & chr(34) & _
"a Macro named, " & chr(34) & strMacroName & Chr(34) & _
"[etcetera]"

I frequently modify my error messages and other messages, and it would be much easier for me to produce my standardized text using a python script; and I would save a lot of time if I could import those error message files into a msgbox prompt field.

I would appreciate any suggestions, that might [1] enable me to import text to Msgbox prompt field from files, and/or [2] help me learn more about call stacks, and how to handle call stack issues.

Thanks,
Marc
Reply With Quote