Advent Day 3 Microsoft Access Guru

VBA > File > Save String As File using VBA

VBA to save a string as a file

Logic

Open, or create, the specified path\filename. Use Print to set the file content equal to the passed string, psFileContents.

Parameters

'*************** 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 *******************************************************

Goto Top  

Share

Share with others ... here's the link to copy:
https://MsAccessGurus.com/VBA/Code/File_SaveStringAsFile.htm

Help to develop

Are you looking for one-on-one help?

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.com

I look forward to hearing from you ~ crystal

Goto Top