Hyperlink to download a csv file

Godders199

Active Member
Joined
Mar 2, 2017
Messages
313
Office Version
  1. 2013
Hello, I am trying to download a csv to an existingspreadsheet, I have the following, I have tried NewWindow true and false makesno difference, always opens a new workbook.

How do I make it download to a specific sheet in the openworkbook?
Sheets("info").Range("A25").Hyperlinks(1).FollowNewWindow:=False, AddHistory:=True

 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
The file will always be open, you can copy the sheet and paste it into your existing sheet, try the following:

Code:
Sub test1()
    Application.ScreenUpdating = False
    Sheets("info").Range("A25").Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
    ActiveSheet.Cells.Copy ThisWorkbook.Sheets("existingSheet").Range("A1")
    ActiveWorkbook.Close
    Application.ScreenUpdating = True
    MsgBox "File inserted in the sheet existingSheet"
End Sub
 
Upvote 0
You could use a text query to download and import the .csv file into the "Other sheet". The macro should be something like this:
Code:
Sub Import_CSV()

    With Worksheets("Other sheet")
        With .QueryTables.Add(Connection:="TEXT;" & Worksheets("info").Range("A25").Hyperlinks(1).Address, Destination:=.Range("A1"))
            .TextFileStartRow = 1
            .TextFileParseType = xlDelimited
            .TextFileCommaDelimiter = True
            .Refresh BackgroundQuery:=False
        End With
        .QueryTables(1).Delete
    End With
    
End Sub
 
Upvote 0
You could use a text query to download and import the .csv file into the "Other sheet". The macro should be something like this:
Code:
Sub Import_CSV()

    With Worksheets("Other sheet")
        With .QueryTables.Add(Connection:="TEXT;" & Worksheets("info").Range("A25").Hyperlinks(1).Address, Destination:=.Range("A1"))
            .TextFileStartRow = 1
            .TextFileParseType = xlDelimited
            .TextFileCommaDelimiter = True
            .Refresh BackgroundQuery:=False
        End With
        .QueryTables(1).Delete
    End With
    
End Sub

Hi this works, but i need the sheet to be in Text format, due to the length of the numbers in some columns. i have tried adding fieldinfo = Array (1,2) for example but this does not work
 
Upvote 0
Try recording a macro with you doing the text query and specifying the required column formats and it should generate the correct TextFileColumnDataTypes = Array(x, x,..._) which you can incorporate into my code.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top