Solved Export a String as CSV (1 Viewer)

XelaIrodavlas

Registered User.
Local time
Today, 13:55
Joined
Oct 26, 2012
Messages
174
Hi all,

I recently asked how to Import CSV data (in the form of a string) into an Access Recordset. But now I need to do the reverse.

I'm running an API request which returns a CSV string, and would like to save that to somewhere on the user's PC. I currently have no idea how to do this. I've tried the TransferText method, but that only works with existing Queries/Tables. Any ideas?

Thanks :)
Alex
 

CJ_London

Super Moderator
Staff member
Local time
Today, 13:55
Joined
Feb 19, 2013
Messages
16,614
one idea is to google your question - you would come up with links like this
 

ebs17

Well-known member
Local time
Today, 14:55
Joined
Feb 7, 2020
Messages
1,946
Code:
Public Sub Append2TextFile(ByVal Content As String, Optional ByVal TextFile As Variant)
    Dim FF As Long
    If IsMissing(TextFile) Then TextFile = CurrentProject.Path & "\Log.txt"
    FF = FreeFile()
    Open TextFile For Append As FF
    Print #FF, Content
    Close #FF
End Sub

'-----------------------------------------------

Append2TextFile sCSVstring, "X:\Anywhere\MyFile.csv"
 

XelaIrodavlas

Registered User.
Local time
Today, 13:55
Joined
Oct 26, 2012
Messages
174
Code:
Public Sub Append2TextFile(ByVal Content As String, Optional ByVal TextFile As Variant)
    Dim FF As Long
    If IsMissing(TextFile) Then TextFile = CurrentProject.Path & "\Log.txt"
    FF = FreeFile()
    Open TextFile For Append As FF
    Print #FF, Content
    Close #FF
End Sub

'-----------------------------------------------

Append2TextFile sCSVstring, "X:\Anywhere\MyFile.csv"
This works perfectly :)

Thanks ebs17, I hadn't considered the similarity between .text and .csv
 

Users who are viewing this thread

Top Bottom