Results 1 to 5 of 5

Thread: [RESOLVED] opening files via commandbutton

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    62

    [RESOLVED] opening files via commandbutton

    I'm trying to find the code to have a web page open from a command button.

    specifically, when I simply press a button on one of my sheets, I want IE to launch and a specific web page to load. (this site is one of them actually).

    I can get excel sheet to load this way but I havent been able to get web pages to load yet. any help would be appreciated.
    Last edited by Albatross; Apr 25th, 2006 at 11:05 AM.

    "If at first you don't succeed, destroy all evidence you ever tried."
    http://www.ussretribution.com

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: opening files via commandbutton

    Try the following
    VB Code:
    1. Private Declare Function ShellExecute _
    2.                             Lib "shell32.dll" _
    3.                             Alias "ShellExecuteA" ( _
    4.                             ByVal hwnd As Long, _
    5.                             ByVal lpOperation As String, _
    6.                             ByVal lpFile As String, _
    7.                             ByVal lpParameters As String, _
    8.                             ByVal lpDirectory As String, _
    9.                             ByVal nShowCmd As Long) _
    10.                             As Long
    11.  
    12. Private Sub Command1_Click()
    13.    Dim r As Long
    14.    r = ShellExecute(0, "open", "WWW.YourWebAddressHere.COM", 0, 0, 1)
    15. End Sub
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    62

    Re: opening files via commandbutton

    My mistake. I specified a commandbutton but neglected to specifcy that I'm using excel.

    I tried adding in the code supplied but getting compile errors.

    "If at first you don't succeed, destroy all evidence you ever tried."
    http://www.ussretribution.com

  4. #4
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: opening files via commandbutton

    Have you added the Private Declare Function statement at the top of the module? it need to be before any procedure?

    I ran this in excel and it worked fine.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    62

    Re: opening files via commandbutton

    That worked this time. thank you!

    "If at first you don't succeed, destroy all evidence you ever tried."
    http://www.ussretribution.com

Posting Permissions

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



Click Here to Expand Forum to Full Width