segunda-feira, 22 de outubro de 2012

Código VBA para salvar planilha EXCEL para arquivo txt



código:

Sub TXT()
Dim i As Double
    Dim nm As String
    nm = ".txt" 'Tipo de extensão a definir
    Open "C:\CAMINHO_NA_SUA_MAQUINA" & nm For Output As #1
    For i = 2 To 1048576
        If Cells(i, 1).Value <> "" Then
            Print #1, Cells(i, 1).Value & ";" & Cells(i, 2).Value & ";" & Cells(i, 3).Value&; ";" & Cells(i, 4).Value&; ";" & Cells(i, 5).Value&; ";" & Cells(i, 6).Value&; ";" & Cells(i, 7).Value&; ";" & Cells(i, 8).Value&; ";" & Cells(i, 9).Value&; ";" & Cells(i, 10).Value&; ";" & Cells(i, 11).Value&; ";" & Cells(i, 12).Value&; ";" & Cells(i, 13).Value&; ";" & Cells(i, 14).Value ''Colunas do Trabalho com separadores a definir
        End If
    Next
    Close #1
    MsgBox ("DOCUMENTO SALVO!")
End Sub


tag: programação
Compartilhe : :

0 comentários:

Postar um comentário

Obrigado por contribuir com este blog!
"Nenhum de nós é mais forte do que todos nós juntos!"