Hi There
I created a MS Word Macro enable document to update the users Outlook Email Signature and copy it to the Email location. All this is working
Now I Want to save values to a Text file (log file) but it must append the text entry into one main "Report.txt"
I got the code to save, below:
I want it to save to: \\172.16.1.41\Apps\Report.txt
However i also want the following values from the VBA :
1) Textbox1 Value - Which is on the UserForm, its the Person Full Name
2) Username - The Username is on the code under "Module1" called : & Environ("username")
3) Date & Time Stamp - The current Date And Time Stamp when the entry save
Attached Sample of the Report.txt file
The Word Document also attached. I want this code to go as a new Macro. So i can call it on Submit button later.
Download Here:
Word Document File
https://ufile.io/4pesw
Report.txt
https://ufile.io/is1lk
Regards
ShabeerSA
I created a MS Word Macro enable document to update the users Outlook Email Signature and copy it to the Email location. All this is working
Now I Want to save values to a Text file (log file) but it must append the text entry into one main "Report.txt"
I got the code to save, below:
Code:
[COLOR=#0000FF][FONT='inherit']Sub [/FONT][/COLOR][COLOR=#444444][FONT='inherit']Example1()[/FONT][/COLOR]
[COLOR=#444444][FONT='inherit'][COLOR=#00B400][FONT=inherit]'the final string to print in the text file [/FONT][/COLOR]
[/FONT][/COLOR][COLOR=#444444][FONT='inherit'][COLOR=#0000FF][FONT=inherit]Dim [/FONT][/COLOR]strData [COLOR=#0000FF][FONT=inherit]As [/FONT][/COLOR][COLOR=#0000FF][FONT=inherit]String [/FONT][/COLOR]
[/FONT][/COLOR][COLOR=#444444][FONT='inherit'][COLOR=#00B400][FONT=inherit]'each line in the original text file [/FONT][/COLOR]
[/FONT][/COLOR][COLOR=#444444][FONT='inherit'][COLOR=#0000FF][FONT=inherit]Dim [/FONT][/COLOR]strLine [COLOR=#0000FF][FONT=inherit]As [/FONT][/COLOR][COLOR=#0000FF][FONT=inherit]String [/FONT][/COLOR]
[/FONT][/COLOR][COLOR=#444444][FONT='inherit']strData = ""
[/FONT][/COLOR][COLOR=#444444][FONT='inherit'][COLOR=#00B400][FONT=inherit]'open the original text file to read the lines [/FONT][/COLOR]
[/FONT][/COLOR][COLOR=#444444][FONT='inherit'][COLOR=#0000FF][FONT=inherit]Open [/FONT][/COLOR]"[FONT=Verdana]\\172.16.1.41\Apps\Report.txt[/FONT]" [COLOR=#0000FF][FONT=inherit]For [/FONT][/COLOR][COLOR=#0000FF][FONT=inherit]Input [/FONT][/COLOR][COLOR=#0000FF][FONT=inherit]As [/FONT][/COLOR]#1
[/FONT][/COLOR][COLOR=#444444][FONT='inherit'][COLOR=#00B400][FONT=inherit]'continue until the end of the file [/FONT][/COLOR]
[/FONT][/COLOR][COLOR=#444444][FONT='inherit'][COLOR=#0000FF][FONT=inherit]While [/FONT][/COLOR]EOF(1) = [COLOR=#0000FF][FONT=inherit]False[/FONT][/COLOR]
[/FONT][/COLOR][COLOR=#444444][FONT='inherit'] [COLOR=#00B400][FONT=inherit]'read the current line of text [/FONT][/COLOR][/FONT][/COLOR]
[COLOR=#444444][FONT='inherit'][COLOR=#0000FF][FONT=inherit] Line [/FONT][/COLOR][COLOR=#0000FF][FONT=inherit]Input [/FONT][/COLOR]#1, strLine [/FONT][/COLOR]
[COLOR=#444444][FONT='inherit'] [COLOR=#00B400][FONT=inherit]'add the current line to strData [/FONT][/COLOR][/FONT][/COLOR]
[COLOR=#444444][FONT='inherit'] strData = strData + strLine & vbCrLf [/FONT][/COLOR]
[COLOR=#444444][FONT='inherit'][COLOR=#0000FF][FONT=inherit]Wend [/FONT][/COLOR]
[/FONT][/COLOR][COLOR=#444444][FONT='inherit'][COLOR=#00B400][FONT=inherit]'add the new line [/FONT][/COLOR]
[/FONT][/COLOR][COLOR=#444444][FONT='inherit']strData = strData + "Data to be appended"
[/FONT][/COLOR][COLOR=#444444][FONT='inherit'][COLOR=#0000FF][FONT=inherit]Close [/FONT][/COLOR]#1
[/FONT][/COLOR][COLOR=#444444][FONT='inherit'][COLOR=#00B400][FONT=inherit]'reopen the file for output [/FONT][/COLOR]
[/FONT][/COLOR][COLOR=#444444][FONT='inherit'][COLOR=#0000FF][FONT=inherit]Open [/FONT][/COLOR]"[FONT=Verdana]\\172.16.1.41\Apps\Report.txt[/FONT]" [COLOR=#0000FF][FONT=inherit]For [/FONT][/COLOR]Output [COLOR=#0000FF][FONT=inherit]As [/FONT][/COLOR]#1
[/FONT][/COLOR][COLOR=#444444][FONT='inherit'][COLOR=#0000FF][FONT=inherit]Print [/FONT][/COLOR]#1, strData
[/FONT][/COLOR][COLOR=#444444][FONT='inherit'][COLOR=#0000FF][FONT=inherit]Close [/FONT][/COLOR]#1
[/FONT][/COLOR][COLOR=#444444][FONT='inherit'][COLOR=#0000FF][FONT=inherit]End [/FONT][/COLOR][COLOR=#0000FF][FONT=inherit]Sub [/FONT][/COLOR][/FONT][/COLOR]
I want it to save to: \\172.16.1.41\Apps\Report.txt
However i also want the following values from the VBA :
1) Textbox1 Value - Which is on the UserForm, its the Person Full Name
2) Username - The Username is on the code under "Module1" called : & Environ("username")
3) Date & Time Stamp - The current Date And Time Stamp when the entry save
Attached Sample of the Report.txt file
The Word Document also attached. I want this code to go as a new Macro. So i can call it on Submit button later.
Download Here:
Word Document File
https://ufile.io/4pesw
Report.txt
https://ufile.io/is1lk
Regards
ShabeerSA