Extract links from Excel document and create .M3u8 files for each url link found in the sheet.

kukaljcanin

New Member
Joined
May 30, 2023
Messages
1
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
I have an Excel document only 2 columns

One is Name of th
e link other it was the link it's self. I am trying to extract all the links in the cells and create .M3u8 files for each link but the naming should be from the the column 1. The excel sheet looks like this but the links are different


What i want is to create news01.m3u8 with the url link found in link.
And like this for every row a file should be greater with the name and link in it. News02/News03.m3u8

I have to his code but it's not ok, any help would be nice
*********

Sub CreateM3U8Files()
Dim linkRange As Range
Dim linkCell As Range
Dim filePath As String
Dim fileNumber As Integer

' Set the range of cells containing the links
Set linkRange = Range("A1:A10") ' Modify this range according to your needs
' Assumes column A contains the links

' Set the folder path where the .m3u8 files will be saved
filePath = "C:\Folder\" ' Modify this path according to your needs

' Loop through each cell in the range
For Each linkCell In linkRange
' Retrieve the link value
Dim link As String
link = linkCell.Value

' Retrieve the corresponding name from the preceding cell
Dim name As String
Dim nameCell As Range
Set nameCell = linkCell.Offset(0, -1)
name = nameCell.Value

' Create a new .m3u8 file for each link
fileNumber = FreeFile
Open filePath & name & ".m3u8" For Output As fileNumber

' Write the link to the file
Print #fileNumber, link

' Close the file
Close fileNumber
Next linkCell

MsgBox "M3U8
files created successfully."
End Sub
*******
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I do not know what exactly is not ok with a code but try this:

VBA Code:
Sub CreateM3U8Files()
Dim linkRange As Range
Dim linkCell As Range
Dim filePath As String
Dim fileNumber As Integer

Set linkRange = Range("B2:B10") ' column with links
filePath = ThisWorkbook.Path & "\" ' Modify this path according to your needs

For Each linkCell In linkRange
    Dim link As String
    link = linkCell.Value   ' links to put inside a file
    Dim name As String
    name = linkCell.Offset(0, -1).Value     ' name of m3u file
    fileNumber = FreeFile
    Open filePath & name & ".m3u8" For Output As fileNumber
    Print #fileNumber, link
    Close fileNumber
Next linkCell
MsgBox "M3U8 files created successfully."
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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