Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Feb 2005
    Posts
    50
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Opening URL in default browser (Excel 2003)

    I'm trying to write a function of the form MyOpenURL(URL,Arg1,Arg2) that would open the nominated URL with the default browser in a new window and return TRUE or FALSE depending on success or otherwise. I'd be grateful if someone could help with the key lines of Code. I've tried "ActiveWorkbook.FollowHyperlink etc" with no success. I'm rather lost. My Visual Basic experience is quite limited.

    regards

    Geoffrey Howell

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Opening URL in default browser (Excel 2003)

    I don't know how to return a boolean specifying whether the URL could be opened if you don't know the browser. The ShellExecute API function will try to open an URL in the default browser, but the return value only indicates whether the browser could be started, not whether the URL could be opened. ActiveWorkbook.FollowHyperlink doesn't return a value at all, but it does use the default browser and it has an argument that lets you specify that the link should be opened in a new window...

  3. #3
    Star Lounger
    Join Date
    Feb 2005
    Posts
    50
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: Opening URL in default browser (Excel 2003)

    Hans, Thank you. I've tried the following line:

    ActiveSheet.FollowHyperlink Address:= "http://www.google.com.au/", NewWindow:= True

    and I can use error control to determine if it works or not. But I can't get that line to work, though it works if I open a file within my computer. I assume I'm doing something wrong. Do you have any thoughts?

    regards

    Geoffrey

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Opening URL in default browser (Excel 2003)

    FollowHyperlink is a method of the Workbook object, not of the Worksheet object. Try

    ActiveWorkbook.FollowHyperlink Address:= "http://www.google.com.au/", NewWindow:= True

    This works on my PC.

  5. #5
    Star Lounger
    Join Date
    Feb 2005
    Posts
    50
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: Opening URL in default browser (Excel 2003)

    Hans, Perfect! Thank you very much.

    Geoffrey

Posting Permissions

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