Notifications
Clear all

Importar txt em uma aba especifica do excel

3 Posts
2 Usuários
0 Reactions
838 Visualizações
(@hyonxd)
Posts: 0
New Member
Topic starter
 

Olá galera !

Estou com um impasse, criei uma macro para importar dados do programa avaya, porem ela só gera um arquivo txt, dele eu criei uma outra macro para importar esse txt para o excel porém ele importa para a planilha que eu deixo o botão, queria fazer com que ele importasse para uma aba tipo "base" e eu deixaria os botão na outra aba "calculos" da mesma planilha.

Está é a macro:

Sub Macro5()
'
' Macro5 Macro
'

'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:UsersDesktoprelatorio.txt", Destination:=Range("$A$1"))
.Name = "chubaca_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 932
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub

 
Postado : 24/10/2016 8:35 am
(@basole)
Posts: 487
Reputable Member
 

Altere esta linha:

With ActiveSheet.QueryTables.Add(Connection:= _ 

Para:

With Thisworkbook.Sheets("Base").QueryTables.Add(Connection:= _
 
Postado : 24/10/2016 8:45 am
(@hyonxd)
Posts: 0
New Member
Topic starter
 

Altere esta linha:

With ActiveSheet.QueryTables.Add(Connection:= _ 

Para:

With Thisworkbook.Sheets("Base").QueryTables.Add(Connection:= _

Quando estou na mesma aba ele importa o arquivo, mas quando estou em uma aba diferente ele da este erro

 
Postado : 24/10/2016 9:09 am