I am attempting to write data from VBA to a text file. My syntax shows no debug or compile errors, but when the method completes and I open the text file it is full of nothing readable. It all appears to be in Chinese. This is my syntax, what is it that is throwing the output off so that it is illegible?
Function WriteData(fulllocale As String, tblName As String, CString As String)
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim Fileout As Object
'Set Fileout = fso.OpenTextFile("C:\Test.txt", ForAppending, True)
Set Fileout = fso.OpenTextFile("C:\Test.txt", 8, True)
Fileout.Write fulllocale & "," & tblName & "," & CString & vbCrLf
Fileout.Close
End Function
Edit - additional info
These are the values being passsed (not the bold text that is a description)
Database Name:C:\Test\db1.accdb
Table Name:Logs
Connection Info:ODBC;DRIVER=SQL Server;SERVER=servername;UID=userid;PWD=password;APP=Microsoft Office 2013;DATABASE=database
Edit 2
This is the syntax I am using to call
Sub Testing()
Dim Fileout As Object
Dim fso As Object
Dim objFSO As Object
Dim accapp As Access.Application
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim colFiles As Collection
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objRegExp As Object
Set objRegExp = CreateObject("VBScript.RegExp")
objRegExp.pattern = ".accdb"
objRegExp.IgnoreCase = True
Set colFiles = New Collection
RecursiveFileSearch "C:\Databases\", objRegExp, colFiles, objFSO
For Each f In colFiles
Set accapp = New Access.Application
accapp.OpenCurrentDatabase (f)
On Error Resume Next
accapp.Visible = False
Set db = accapp.CurrentDb
For Each tdf In db.TableDefs
If Not (tdf.Name Like "MSys*") Then
WriteData CStr(f), tdf.Name, tdf.Connect
End If
Next
Set tdf = Nothing
Set db = Nothing
Next
Set objFSO = Nothing
Set objRegExp = Nothing
End Sub