• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2385
  • Last Modified:

Create text file Access VBA

I need to be able to write text to a text file. I am trying it with the VBA open file append. But when I write to file it puts double quote on the ends of the line. Does anyone have a solution where I can write the text with no quotes?
2 Solutions
Try using PRINT instead of WRITE.  The latter add quotation marks around strings.
Luke ChungPresidentCommented:
How about something like this:

Public Function CreateFileFromText(strFileName As String, strText As String) As Boolean
  ' Comments: Create (save) a file containing the text you provide
  ' Params  : strFileName           File name to create (including full path)
  '           strText               Text to put into the file
  ' Returns : True if successful, False if not
  ' Source  : Total Visual SourceBook
  On Error GoTo PROC_ERR
  Dim intFile As Integer
  ' Assume failure
  CreateFileFromText = False
  intFile = FreeFile
  Open strFileName For Output As #intFile
  Print #intFile, strText
  Close #intFile
  CreateFileFromText = True
  Exit Function
  MsgBox "Error: " & Err.Number & ". " & Err.Description, , "modFileDisk.CreateFileFromText"
  Resume PROC_EXIT
End Function

Open in new window

IdaracAuthor Commented:
Thank you both
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now