VB and VBA Users Source Code: Creating a Touch File
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Creating a Touch File
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Friday, May 07, 2004
Hits:
3104
Category:
Files/Directories/IO
Article:
It is often useful to be able to create an empty file or a file with a message in it. The simple function below can be used to create such files. 'Purpose : Creates a file with an optional text content 'Inputs : sFilename The name of the file to create. ' sText The contents of the file. 'Outputs : Returns True on success 'Author : Andrew Baker 'Date : 25/03/2000 'Notes : Similiar to the Perl "Touch" command Function Touch(sFilename As String, Optional sText As String = "") As Boolean Dim iFreeFile As Integer On Error GoTo ErrFailed iFreeFile = FreeFile Open sFilename For Output As #iFreeFile Print #iFreeFile, sText Close iFreeFile Touch = True Exit Function ErrFailed: Touch = False Debug.Print Err.Description Debug.Assert False Close iFreeFile End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder