+ Reply to Thread
Results 1 to 20 of 20

Follow Hyperlink question.

  1. #1
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Central Ohio
    MS-Off Ver
    Excel 2000, and 2010
    Posts
    654

    Follow Hyperlink question.

    A few days ago I wanted to add a button to a sheet to activate a Hyperlink to a file on my computer. FDibbins responded and the result is fine. I wanted to add some more buttons on the same sheet to open different files but I can't get them to work. I first copied the code changed the target and nothing. I then tried adding a separate module and that doesn't work either. The only thing I have been able to return is a "Run-Time error '-2147221014(80040lea)' ". IS is possible to do this and if so how do I go about it. Here is the code I have.

    Please Login or Register  to view this content.
    Thanks.
    Jim O
    Last edited by JO505; 01-24-2013 at 11:44 AM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Follow Hyperlink question.

    Did the code I posted not work?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Central Ohio
    MS-Off Ver
    Excel 2000, and 2010
    Posts
    654

    Re: Follow Hyperlink question.

    No. The code works fine but a would like to add some more buttons to the same sheet to open different files and I can't get them to work. The first setup is great.

    I don't know if I need to do anything special, add another line somewhere, put it in a seperate modual or what. I have changed the target range in the new code but still no result except the erroe msg.

    Jim O

  4. #4
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Central Ohio
    MS-Off Ver
    Excel 2000, and 2010
    Posts
    654

    Re: Follow Hyperlink question.

    Here are both codes that I am trying to use. The code assigned to command button 1 (cell C7) works fine, I cannot get the second code, assigned to command button 2 (cell E15), to function.

    Please Login or Register  to view this content.
    Anyone have any thoughts on this?

    Jim O

  5. #5
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Central Ohio
    MS-Off Ver
    Excel 2000, and 2010
    Posts
    654

    Re: Follow Hyperlink question.

    I am still unable to get a second command button to work, only the first one works. I am a an impass. I don't even know if it is possible.

    Any thoughts on this issue?

    Jim O

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Follow Hyperlink question.

    Is the URL in E15 valid?

  7. #7
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Central Ohio
    MS-Off Ver
    Excel 2000, and 2010
    Posts
    654

    Re: Follow Hyperlink question.

    Yes it works if I click on it without using the button but if I try the button I get a run-time error. If I click on the debugger "ThisWorkbook.FollowHyperlink strURL" is highlited.

    Jim O

  8. #8
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Central Ohio
    MS-Off Ver
    Excel 2000, and 2010
    Posts
    654

    Re: Follow Hyperlink question.

    Does anone have any thoughts on this issue?

    Jim O

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Jim

    Do you just want to open the files?

    If you do perhaps it can be done without hyperlinks.

  10. #10
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Central Ohio
    MS-Off Ver
    Excel 2000, and 2010
    Posts
    654

    Re: Follow Hyperlink question.

    I am not sure what you are asking. With the original code I set up a command button to open a specific file and it works properly. I would like to add some more buttons to open other files but I have not had any sucess. I copied the first code, and changed the references but I still have not been able to get them to work. My first question is, is this something that is even possible? It seams as though it should work but I have no idea.

    If their is another way to to open files without using a hyperlink, I am interested in learning about it.

    Jim O

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Yes there are other ways to open files.

    What type of files are you working with?

  12. #12
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Central Ohio
    MS-Off Ver
    Excel 2000, and 2010
    Posts
    654

    Re: Follow Hyperlink question.

    Excel .xlsx and .xlsm . They are data files on my hard drive.

    Jim O

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Follow Hyperlink question.

    You could open them with Workbooks.Open.

    For example, assuming C7 has a valid path and filename.
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Central Ohio
    MS-Off Ver
    Excel 2000, and 2010
    Posts
    654

    Re: Follow Hyperlink question.

    I am still having an issue.

    I copied and pasted the code, changed the button and cell references to thappropriatete value and I am still getting an error mgs. If I click on debug the "Workbooks.Open strURL" ihighlighteded in yellow. This is what I was getting with the first code. I can click on the link in the sheet with the mouse and the file opens but it wont open using a button although the original code and button work.

    Jim O

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Follow Hyperlink question.

    Jim

    What exactly is strURL when you get the error?

  16. #16
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Central Ohio
    MS-Off Ver
    Excel 2000, and 2010
    Posts
    654

    Re: Follow Hyperlink question.

    Sorry for my ignorance with this but I am not sure I understand what you are saying.

    All I know is that I can set up a hyperlink and it will only work if I click it with a mouse, if I assign a command button to it I get an error. However the first button I put on the sheet WILL work with a button. I have not been able to get any others to work from a command button. I have even tried to assign the first button with a different file ( that I can open with a mouse click) and I get an error msg. I am totally stumped.

    Jim O

  17. #17
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Follow Hyperlink question.

    Jim

    To be honest I'm not quite sure what you are trying to do.

    Why do you want to open these files?

  18. #18
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Central Ohio
    MS-Off Ver
    Excel 2000, and 2010
    Posts
    654

    Re: Follow Hyperlink question.

    Again, what I want to do is to click on a button and have a file open. As to why I want to open them, I find it much easier to work on them if they are open.

    I am just trying to understand why the code works sometime and not other times.

    Jim O

  19. #19
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Follow Hyperlink question.

    did you change the target of the button to call CommandButton2_Click()?

    each button should be targeted at their own macro

    also, since it it is looking at a value (strURL = Worksheets("Select Customer").Range("E15").Value) the value showing has to be the correct link address and not just a label
    ie. if the value showing is Invoice 2, and the link address is \\drive\folder\Invoice 2.xlsx then strURL will equal Invoice 2 not \\drive\folder\Invoice 2.xlsx

  20. #20
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Central Ohio
    MS-Off Ver
    Excel 2000, and 2010
    Posts
    654

    Re: Follow Hyperlink question.

    Scott,

    That is the answer I was looking for. I had set up a link using a word rather than an address to the file. It would work if I clicked on the hyperlink but the code was looking for the actual address of the file.

    Many thanks!

    Jim O

+ 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