VBA to save a string as a file
Open, or create, the specified path\filename. Use Print to set the file content equal to the passed string, psFileContents.
'*************** Code Start ***************************************************** ' Purpose : Create (or modify) a file whose contents is a specified string ' Author : crystal (strive4peace) ' web site : https://msaccessgurus.com ' This code:https://msaccessgurus.com/VBA/Code/File_SaveStringAsFile.htm ' LICENSE : ' You may freely use and share this code, but not sell it. ' Keep attribution. Mark your changes. Use at your own risk ' Code List: msaccessgurus.com/code.htm '---------------------------------------------------------------------------------------' SaveStringAsFile
'--------------------------------------------------------------------------------------- ' Public Sub SaveStringAsFile (psPathFile As String, psFileContents As String) '160730 strive4peace Dim iFile As Integer iFile = FreeFile Open psPathFile For Output As iFile Print #iFile, psFileContents Close iFile End Sub '*************** Code End *******************************************************
Share with others ...
here's the link to copy:
https://MsAccessGurus.com/VBA/Code/File_SaveStringAsFile.htm
Let's connect and team-develop while we build your application together. As needed, I'll pull in code and features from my vast libraries, cutting out lots of development time, and you learn how it is done. Each step of the way, you guide from your perspective and infuse your goals and ideas. The melding of what we both can do results in a successful application.
Email me
training@msAccessGurus
I look forward to hearing from you ~ crystal