+ Reply to Thread
Results 1 to 9 of 9

Adding a Hyperlink, but changing the name of the downloaded file.

  1. #1
    Registered User
    Join Date
    08-09-2018
    Location
    lake elmo mn
    MS-Off Ver
    2016
    Posts
    8

    Adding a Hyperlink, but changing the name of the downloaded file.

    Hello! Another one I'm having trouble with.

    In HTML you can add download=changedname.xyz to an <a> tag.
    and the file will download as the changed name.

    Goal: I'd like to append some info within the spreadsheet to the filename from a URL.

    To add the hyperlink to a column I'm using .Hyperlink Add, but it doesn't seem to have that functionality to then modify the name once the link is clicked (downloaded).

    Any thoughts on tools that can be used?

    Col A is order of view (1st to 10th)
    Col B is a hyperlink with the TextToDisplay as image, audio, or video that links to the downloadable file (ex: Bobsart.xyz)

    Goal: When I click on the image hyperlink it downloads as 1stBobsart.xyz

    Thank you!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Adding a Hyperlink, but changing the name of the downloaded file.

    Hello karlwarnkester,

    You can change the file name and location of the downloaded file using a hyperlink but is not as easy as in HTML. On your worksheet you will need two cells. The first will have the hyperlink to the file to be downloaded. This can be any file type. The second cell will have the new file name and extension. You can include the drive letter in the path also in the new file name.

    Next, the hyperlink as to be captured using the "Worksheet_FollowHyperlink" event. Once the link is made, control is returned by to the VBA macro. The macro will then download the file from the URL and save it to the directory in the new file name. I have attached a workbook that is setup to do this.

    Macro to Download File from Website
    Please Login or Register  to view this content.
    Worksheet Event Code
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    08-09-2018
    Location
    lake elmo mn
    MS-Off Ver
    2016
    Posts
    8

    Re: Adding a Hyperlink, but changing the name of the downloaded file.

    Wow! Thanks for all of that work! You certainly are a very skilled and knowledgeable programmer.

    It will take me some time to go through and learn all of this, I like to know what each thing is doing and I'm new to all of this. Thanks so much, I'll dive in.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Adding a Hyperlink, but changing the name of the downloaded file.

    Hello karlwarnkester,

    Did it work the way you wanted?

  5. #5
    Registered User
    Join Date
    08-09-2018
    Location
    lake elmo mn
    MS-Off Ver
    2016
    Posts
    8

    Re: Adding a Hyperlink, but changing the name of the downloaded file.

    Still figuring it out. Looking at my workflow and how your code fits with that.

    It might get complicated.

    I received an excel file with the data already in the tables. Column J has the html link already there.
    Currently I have another macro so I can Select the cells and Open the links, instead of clicking on them individually. Column H has the review order (1st-10th) and that is the string I want to append to the file.

    Your code might just do the trick, I just have to work on it a bit more to see.
    Last edited by karlwarnkester; 08-22-2019 at 02:13 PM.

  6. #6
    Registered User
    Join Date
    08-09-2018
    Location
    lake elmo mn
    MS-Off Ver
    2016
    Posts
    8

    Re: Adding a Hyperlink, but changing the name of the downloaded file.

    Basically I have an excel sheet that acts as a program (I call command center), I import the other data from another excel spreadsheet, then format the results, add clickable URL to rows, etc.

    A lot of your code is things I have to lookup and/or investigate what's going where and how

  7. #7
    Registered User
    Join Date
    08-09-2018
    Location
    lake elmo mn
    MS-Off Ver
    2016
    Posts
    8

    Re: Adding a Hyperlink, but changing the name of the downloaded file.

    What if I wanted a duplicate file download to occur? EXAMPLE: If you run the test twice, it does not create a file Excel Forum(1).ico or whatever Windows does for redundant filenames. I tried to remove the "Remove any old copies of the file." Part But it didn't do the trick.
    Why would I want to do that (you might ask)?
    I don't have control of the incoming data and someone could put in two 1st with the same file name. In this case I would like them to both show up in the downloads folder.

    Overall I'm still fighting the battle to get it to work for me.

  8. #8
    Registered User
    Join Date
    08-09-2018
    Location
    lake elmo mn
    MS-Off Ver
    2016
    Posts
    8

    Re: Adding a Hyperlink, but changing the name of the downloaded file.

    Not quite working yet.

    Please Login or Register  to view this content.

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Adding a Hyperlink, but changing the name of the downloaded file.

    Hello karlwarnkester,

    This code is amended to look for a duplicate file and then append a sequence number (1) to the name.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Changing username in file path Hyperlink
    By ImranBhatti in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-19-2018, 07:32 AM
  2. Changing Color of Hyperlink if file not attached
    By Newk2006 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-03-2015, 08:07 AM
  3. Wildcard in Hyperlink to reference file in changing locations
    By PhilipHanekom in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-01-2014, 09:32 AM
  4. Hyperlink and changing file name
    By Martinbif in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-05-2013, 08:10 PM
  5. [SOLVED] checking file exists before adding hyperlink
    By TaliKL in forum Excel General
    Replies: 8
    Last Post: 03-02-2013, 06:26 AM
  6. Hyperlink to a changing file name
    By declangallen in forum Excel General
    Replies: 1
    Last Post: 01-18-2011, 09:35 PM
  7. Macro problem - stops after the hyperlink is downloaded
    By RBI in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-30-2008, 08:27 PM

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