+ Reply to Thread
Results 1 to 4 of 4

Macro for selecting & saving a MP4 file from Excel file

  1. #1
    Registered User
    Join Date
    03-13-2010
    Location
    Mumbai, India
    MS-Off Ver
    2007 & 2013
    Posts
    28

    Question Macro for selecting & saving a MP4 file from Excel file

    Hello All,

    I have some knowledge of Excel VB.

    I am currently working on an excel file whcih contains a list of songs. The users can select a song by using a pulldown list.

    An option of dosnloading the song is to be given to the user. All he / she has to do is to click a command button to save the MP4 file on their hard disc.

    How can I achieve this?

    Hope someone can help me in this regard....thank you all.

    xlman

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Macro for selecting & saving a MP4 file from Excel file

    Hello xlman,

    welcome to the forum.

    If the user works with the Excel file and the file lists mp4 files, where exactly would these mp4 files be? Are you referring to files on the web? In that case, you'd need to provide more than just the MP4 name. You'd also need to specify the full URL of the download. Then you could maybe just use a hyperlink?

  3. #3
    Registered User
    Join Date
    03-13-2010
    Location
    Mumbai, India
    MS-Off Ver
    2007 & 2013
    Posts
    28

    Re: Macro for selecting & saving a MP4 file from Excel file

    First of, thanks for the response.

    Sorry, i didn't give details.
    Its like this... all songs are stored on a server.
    Users can select the song using an excel file in which a pulldown list is given indicating song names.
    user selects a song and clicks on a button to save it on his pc.
    In the excel file, user's log-in id will be stored and that song will not be available to anyone else till this user uploads it back to server.

    Hope, I have given clear idea now.

    Thanks again

  4. #4
    Registered User
    Join Date
    03-13-2010
    Location
    Mumbai, India
    MS-Off Ver
    2007 & 2013
    Posts
    28

    Re: Macro for selecting & saving a MP4 file from Excel file

    Hello All,

    I have one code given below which is now working. But in this code physically file name or extension has to be entered.

    Sub Download_file()
    'This macro copy a file from From Source Path to To Destination Path.

    Dim FSO As Object
    Dim FromFolder As String
    Dim ToFolder As String
    Dim FileTyp As String

    FromFolder = "C:\My Folder" ' The source can be a folder on a server. In this case use \\server\folder\
    ToFolder = "C:\Backup" ' The destination folder cab ne on user's hard disc

    FileTyp = "*.mp4" 'can use *.* for all files or *.doc for word files

    If Right(FromFolder, 1) <> "\" Then
    FromFolder = FromFolder & "\"
    End If

    Set FSO = CreateObject("scripting.filesystemobject")

    ' If sorce folder is not found, gives message & exits the program
    If FSO.FolderExists(FromFolder) = False Then
    MsgBox FromFolder & " doesn't exist. Exiting..."
    Exit Sub
    End If

    ' Checks if destination folder exists. If not, it will be created
    If FSO.FolderExists(ToFolder) = False Then
    MsgBox ToFolder & " doesn't exist, it will create now"
    MkDir ToFolder
    End If

    ' File downloading process
    FSO.CopyFile Source:=FromFolder & FileTyp, Destination:=ToFolder
    MsgBox "File " & FileTyp & " downloaded in " & ToFolder

    End Sub

    What I want is to add following lines at the start of code

    ' Get the file name from Cell "G7"
    Dim file_name As String
    file_name = Range("G7") ' picks up the file name from Cell G7 where a pulldown list appears

    Then I want to replace

    FileTyp = "*.mp4" with

    FileTyp = file_name

    However, it dosen't work. I am getting an error as
    Run-time error "70"

    permission denied.


    Pl help to resolve this problem.

    Thanks
    xlman
    Last edited by xlman; 03-14-2010 at 03:57 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1