Bom dia a todos
Neste exemplo do João Paulo que estou a exportar para Texto como posso alterar o nome de teste?
Public Sub Grava_Txt(ByVal Caminho As String)
Dim N As Integer
Dim rst As Recordset
N = FreeFile
Set rst = CurrentDb.OpenRecordset("MinhaTabela")
Open Caminho For Output As #N
Do While Not rst.EOF
Print #N, rst!Produto
rst.MoveNext
Loop
Set rst = Nothing
Close #N
End Sub
Private Sub Command0_Click()
'Call Grava_Txt("c:\Teste.txt")
Dim strPath As String
Dim intFile As Integer
Dim strLine As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
On Error Resume Next
strPath = "C:\Teste.TXT" 'como posso mudar Teste pata outro Nome?'
If Len(strPath) = 0 Then Exit Sub
intFile = FreeFile
Open strPath For Append Access Write Lock Read Write As #intFile
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("MinhaTabela") 'É uma Tabela!
While Not rst.EOF
Print #intFile, (rst!MeuCampo),
rst.MoveNext
Wend
On Error Resume Next
If Not rst Is Nothing Then
rst.Close
Set rst = Nothing
End If
If Not dbs Is Nothing Then
Set dbs = Nothing
End If
Close #intFile
Exit Sub
End Sub
Obrigado
Pina
Neste exemplo do João Paulo que estou a exportar para Texto como posso alterar o nome de teste?
Public Sub Grava_Txt(ByVal Caminho As String)
Dim N As Integer
Dim rst As Recordset
N = FreeFile
Set rst = CurrentDb.OpenRecordset("MinhaTabela")
Open Caminho For Output As #N
Do While Not rst.EOF
Print #N, rst!Produto
rst.MoveNext
Loop
Set rst = Nothing
Close #N
End Sub
Private Sub Command0_Click()
'Call Grava_Txt("c:\Teste.txt")
Dim strPath As String
Dim intFile As Integer
Dim strLine As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
On Error Resume Next
strPath = "C:\Teste.TXT" 'como posso mudar Teste pata outro Nome?'
If Len(strPath) = 0 Then Exit Sub
intFile = FreeFile
Open strPath For Append Access Write Lock Read Write As #intFile
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("MinhaTabela") 'É uma Tabela!
While Not rst.EOF
Print #intFile, (rst!MeuCampo),
rst.MoveNext
Wend
On Error Resume Next
If Not rst Is Nothing Then
rst.Close
Set rst = Nothing
End If
If Not dbs Is Nothing Then
Set dbs = Nothing
End If
Close #intFile
Exit Sub
End Sub
Obrigado
Pina