Usuários do Excel
Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

erro CommanType = 0

2 participantes

Ir para baixo

erro CommanType = 0 Empty erro CommanType = 0

Mensagem por eduardo campos Qua Ago 28, 2013 4:43 pm

Galera, a unica coisa que eu sei sobre macro, é clicar em nova macro e gravar os passos.
Sendo assim eu criei uma macro para importar aquivos txt para a planilha, mas sempre ocorrre o erro: ERRO NO TEMPO DE EXECUÇÃO '5'
ARGUMENTO OU CHAMADA DE PROCEDIMENTO INVALIDA
Em depurar o codigo fica com erro no CommandType = 0.
Alguem sabe me ajudar?

Sub Antenas_teste()
'
' Antenas_teste Macro
'

'
Sheets("WS2000_01").Select
Columns("A:D").Select
Selection.Delete Shift:=xlToLeft
Sheets("WS2000_02").Select
Columns("A:D").Select
Selection.Delete Shift:=xlToLeft
Sheets("WS2000_03").Select
Columns("A:D").Select
Selection.Delete Shift:=xlToLeft
Sheets("AP5131_01").Select
Columns("A:D").Select
Selection.Delete Shift:=xlToLeft
Sheets("AP5131_02").Select
Columns("A:D").Select
Selection.Delete Shift:=xlToLeft
Sheets("WS2000_01").Select
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\Antenas\WS2000_01.txt" _
, Destination:=Range("$A$1"))
.CommandType = 0
.Name = "WS2000_01"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(12, 12, 21)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Sheets("WS2000_02").Select
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\Antenas\WS2000_02.txt" _
, Destination:=Range("$A$1"))
.CommandType = 0
.Name = "WS2000_3"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(12, 14, 19)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Sheets("WS2000_03").Select
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\Antenas\WS2000_03.txt" _
, Destination:=Range("$A$1"))
.CommandType = 0
.Name = "WS2000_4"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(12, 14, 19)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Sheets("AP5131_01").Select
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\Antenas\AP5131_01.txt" _
, Destination:=Range("$A$1"))
.CommandType = 0
.Name = "AP5131_2"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(12, 14, 19)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Sheets("AP5131_02").Select
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\Antenas\AP5131_02.txt" _
, Destination:=Range("$A$1"))
.CommandType = 0
.Name = "AP5131_3"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(12, 14, 19)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Sheets("Dados").Select
Range("B3").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(WS2000_01!C[2],""=TTL=64"")"
Range("K3").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(WS2000_02!C[-7],""=TTL=64"")"
Range("B12").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(WS2000_03!C[2],""=TTL=64"")"
Range("K12").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(AP5131_01!C[-7],""=TTL=64"")"
Range("B22").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(AP5131_02!C[2],""=TTL=64"")"
Range("B23").Select
End Sub

eduardo campos
Iniciante
Iniciante

Mensagens : 1
Data de inscrição : 28/08/2013

Ir para o topo Ir para baixo

erro CommanType = 0 Empty Re: erro CommanType = 0

Mensagem por alexandrevba Qua Out 02, 2013 9:50 am

Bom dia!!
Você está importando para formato de tableas??
Veja na ajuda do (F1) do Editor VB, leia também
http://msdn.microsoft.com/en-us/library/office/ff840602.aspx

[quote]Chamada de procedimento ou argumento inválido (Erro 5)
Consulte também     Informações específicas

Alguma parte da chamada não pode ser concluída. As causas e soluções desse erro são as seguintes:

Um argumento provavelmente excede o intervalo de valores permitidos. Por exemplo, a função Sin pode aceitar somente valores dentro de um certo intervalo. Argumentos positivos menores que 2.147.483.648 são aceitos, enquanto 2.147.483.648 gera este erro.
Verifique os intervalos permitidos para argumentos.

Este erro também pode ocorrer se for feita uma tentativa para chamar um procedimento que não seja válido na plataforma atual. Por exemplo, alguns procedimentos podem ser válidos somente para o Microsoft Windows, ou para o Macintosh, e assim por diante.
Verifique as informações específicas da plataforma sobre o procedimento.

Para obter informações adicionais, selecione o item em questão e pressione F1 (no Windows) ou HELP (no Macintosh).
[quote]
alexandrevba
alexandrevba
Intermediário
Intermediário

Mensagens : 222
Data de inscrição : 26/06/2012
Localização : Serra-ES

Ir para o topo Ir para baixo

Ir para o topo

- Tópicos semelhantes

 
Permissões neste sub-fórum
Não podes responder a tópicos