Multiple data import from text files

Nils_Junker

Board Regular
Joined
Jun 2, 2023
Messages
80
Office Version
  1. 365
Platform
  1. Windows
Hi everybody,

I got the following problem:

I need to get data from round about 500 text files.
Problem one is that I just need a part of each text file, (the part I need always stays the same)
Problem two is that I dont have enough time to manually convert all the text files one by one.

The following link shows all the files I want to include in my excel


Also how many lines can i insert in Excel?

If you need further Information, please send me an info!

Thanks for your help!
 
Add this first line of code where indicated and then run the code selecting one file to download.

This should tell you where and what it is trying to save.

VBA Code:
        MsgBox strDownloadFolder & "\" & strFilename, vbOKOnly, "Error Line"
    
        If objXmlHttpReq.Status = 200 Then
            Set objStream = CreateObject("ADODB.Stream")
            objStream.Open
            objStream.Type = 1
            objStream.Write objXmlHttpReq.responseBody
            objStream.SaveToFile strDownloadFolder & "\" & strFilename, 2
            objStream.Close
        End If
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Add this first line of code where indicated and then run the code selecting one file to download.

This should tell you where and what it is trying to save.

VBA Code:
        MsgBox strDownloadFolder & "\" & strFilename, vbOKOnly, "Error Line"
  
        If objXmlHttpReq.Status = 200 Then
            Set objStream = CreateObject("ADODB.Stream")
            objStream.Open
            objStream.Type = 1
            objStream.Write objXmlHttpReq.responseBody
            objStream.SaveToFile strDownloadFolder & "\" & strFilename, 2
            objStream.Close
        End If

this is the message i am now getting
 
Last edited by a moderator:
Upvote 0
View attachment 93850
this is the message i am now getting
What value have you got assigned to the strDownloadFolder variable as the folder into which the downloaded
zip file is to be saved?

This is what it should be:
strDownloadFolder= ThisWorkbook.Path & "\Downloads\"

You should have a 'Downloads' folder in the folder containing the workbook.
You should have an 'Unzipped' folder in the 'Downloads' folder.
 
Upvote 0
What value have you got assigned to the strDownloadFolder variable as the folder into which the downloaded
zip file is to be saved?

This is what it should be:
strDownloadFolder= ThisWorkbook.Path & "\Downloads\"

You should have a 'Downloads' folder in the folder containing the workbook.
You should have an 'Unzipped' folder in the 'Downloads' folder.
My folder organisation looks like this:

1687159953062.png


where can i see what value there is assigned (at which line, can't find it)

this here:
1687160079079.png
 
Upvote 0
Does this appear anywhere else in the module?

strDownloadFolder=

What drive are you on?

I'm on my C drive.
 
Upvote 0
Does this appear anywhere else in the module?

strDownloadFolder=

What drive are you on?

I'm on my C drive.
so i converted my workbook folder also to the c drive.
now it looks like this
1687160746473.png


and no there is no other line containing strDownloadFolder =
 
Upvote 0

Forum statistics

Threads
1,223,921
Messages
6,175,379
Members
452,639
Latest member
RMH2024

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