Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
Por Elo
#46020
Oi Gente.

Encontrei no fórum uma macro feita pelo Laender em que importa txt e ainda com uma barra de progresso.

Alguém pode me ajudar para que o txt importe a partir da linha 2? Atualmente ela importa na linha 1.
Você não está autorizado a ver ou baixar esse anexo.
Por Elo
#46102
OI gente abaixo apresento a macro. Alguém pode me dar pelo menos um caminho para que eu mesma faça isso?
Código: Selecionar todos
Private Sub cmdImportar_Click()



    Dim objFSO As Object, objTextFile As Object
    Dim iFF As Integer
    Dim sLinha As String
    Dim QtyLinhas As Long, i As Long
    
    If Dir(txtCaminho) = vbNullString Then MsgBox "Arquivo não encontrado", vbExclamation: Exit Sub
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFSO.OpenTextFile(txtCaminho.Value)
    
    'Lê todo o arquivo
    objTextFile.ReadAll
    QtyLinhas = objTextFile.Line
    
    'configura a ProgressBar
    pb.Max = QtyLinhas
    pb.Value = 0
    
    iFF = FreeFile
    Open txtCaminho For Input As iFF
        
    'Limpa os dados da planilha que irá receber
    shtDados.Cells.Clear
    
        
    'Faz leitura do arquivo linha a linha
    Do While Not EOF(iFF)
        i = i + 1
        Line Input #iFF, sLinha
        
        arrData = Split(sLinha, "|")
        shtDados.Cells(i, 1) = UBound(arrData) - 1
        
        For j = 2 To UBound(arrData)
            shtDados.Cells(i, j).NumberFormat = "@"
            shtDados.Cells(i, j) = arrData(j - 1)
        Next j
        
        pb.Value = i
        
    Loop
    
    shtDados.Columns.AutoFit
    shtDados.Columns(1).Hidden = True
    Unload Me
    MsgBox "Arquivo importado com sucesso", vbInformation
        
    Close iFF
        
End Sub


Private Sub cmdSelecionar_Click()
    Dim sArquivo As Variant
    Dim sTipo As String, sTitulo As String
    
    sTipo = "Arquivo SPED (*.txt),*.txt"
    sTitulo = "Selecione um arquivo"
    
    sArquivo = SelecionarArquivo(sTipo, sTitulo, False)
    
    If TypeName(sArquivo) = "String" Then
        txtCaminho = sArquivo
    
    End If
End Sub
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord