Hi Curos,
You'll need to write VBA code that opens a recordset on the table and
works through it line by line, something like this:
Dim dbD As DAO.Recordset
Dim rsR as DAO.Recordset
Dim strBasePath As String
Dim lngRecNo as Long
Dim strFileName As String
Set dbD = CurrentDB()
Set rsR = dbD.OpenRecordset("MyTable")
strBasePath = "D:\Folder\"
lngRecNo = 1
Do Until rsR.EOF
strFileName = strBasePath & CStr(lngRecNo) & ".doc"
'Export first record
...
.MoveNext
lngRecNo = lngRecNo + 1
Loop
rsR.Close
Set rsR = Nothing
Set dbD = Nothing
You say "1.doc". Does this imply you want to export them to Word
documents? If so, exporting each record will mean using Automation
creating a Word document and poke the field values into it (see e.g.
Sample OLE Automation for MS Word and MS Excel
http://support.microsoft.com/?id=123859
Opening a new Word document based on a template through Automation
http://www.mvps.org/access/modules/mdl0043.htm
If you want to export to a text file, you can just assemble the fields
into a string the way you want, and then write it to disk using the
function at the end of this message, e.g.
...
With rsR
strText = .Fields("FirstName") & " " _
& .Fields("LastName") & ": " _
& .Fields("Phone")
End With
lngRetVal = WriteToFile(strText, strFileName)
If lngRetVal <> 0 Then
MsgBox "Couldn't write " & strFileName
End if
...
Function WriteToFile(Var As Variant, _
FileSpec As String, _
Optional Overwrite As Long = True) _
As Long
'Writes Var to a textfile as a string.
'Returns 0 if successful, an errorcode if not.
'Overwrite argument controls what happens
'if the target file already exists:
' -1 or True (default): overwrite it.
' 0 or False: append to it
' Any other value: abort.
Dim lngFN As Long
On Error GoTo Err_WriteToFile
lngFN = FreeFile()
'Change Output in next line to Append to
'append to existing file instead of overwriting
Select Case Overwrite
Case True
Open FileSpec For Output As #lngFN
Case False
Open FileSpec For Append As #lngFN
Case Else
If Len(Dir(FileSpec)) > 0 Then
Err.Raise 58 'File already exists
Else
Open FileSpec For Output As #lngFN
End If
End Select
Print #lngFN, CStr(Nz(Var, ""));
Close #lngFN
WriteToFile = 0
Exit Function
Err_WriteToFile:
WriteToFile = Err.Number
End Function