Excel - VBA + Obtener info desde API

 
Vista:

VBA + Obtener info desde API

Publicado por Juani (2 intervenciones) el 03/06/2019 04:09:30
Hola,
Estoy intentando armar un código de VBA para importar un archivo .CSV desde una pagina web pero no logro dar en la tecla despues de reviar muchos tutoriales y páginas.

El archivo que debo obtener se decarga directamente desde el siguiente link:
http://infra.datos.gob.ar/catalog/sspm/dataset/74/distribution/74.3/download/intercambio-comercial-argentino-mensual.csv

Desde ya quien me pueda ayudar le estaré agradecido.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Norberto
Val: 148
Ha mantenido su posición en Excel (en relación al último mes)
Gráfica de Excel

VBA + Obtener info desde API

Publicado por Norberto (46 intervenciones) el 03/06/2019 13:01:20
Hola:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Sub Prueba()
 
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://infra.datos.gob.ar/catalog/sspm/dataset/74/distribution/74.3/download/intercambio-comercial-argentino-mensual.csv" _
        , Destination:=Range("$A$1"))
        .Name = "DatosExternos_5"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = False
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlAllTables
        .WebFormatting = xlWebFormattingAll
        .WebPreFormattedTextToColumns = False
        .WebConsecutiveDelimitersAsOne = False
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = True
        .Refresh BackgroundQuery:=False
    End With
    Range("A1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range("A1:A" & ActiveSheet.UsedRange.Rows.Count).Select
    Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
        Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
        :=Array(Array(1, 5), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
        Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1 _
        ), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1)), _
        DecimalSeparator:=".", ThousandsSeparator:=",", TrailingMinusNumbers:= _
        True
    Columns("A:R").EntireColumn.AutoFit
End Sub

Un saludo,

Norberto.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar

VBA + Obtener info desde API

Publicado por Juan Ignacio (2 intervenciones) el 03/06/2019 19:44:23
Excelente Norberto!!! Muchas graciass!! funciona super bien y además acomoda el formato!!!!

De nuevo gracias!!!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar