Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Link to HTM

Status
Not open for further replies.

be17

Technical User
Feb 7, 2001
26
US
Does anyone know if it is possible to write a macro that will connect you to a webpage. What I would like to do is create a toolbar button so that when the user clicks on the button, it will send them to a particular site on our intranet. Any suggestions?
 
This is what I use in "regular" VB to "spawn" a browser with a given URL. Put this in a MODULE under your document
Code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" _
    Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation _
    As String, ByVal lpFile As String, ByVal lpParameters As String, _
        ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


Public Sub Navigate(strUrl As String) 
    Dim hWnd As Long
    Navigate = ShellExecute(hWnd, vbNullString, strUrl, vbNullString, _
                    vbNullString, vbNormalFocus)
End Function
 
Correction.
Code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" _
    Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation _
    As String, ByVal lpFile As String, ByVal lpParameters As String, _
        ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


Public Sub Navigate(strUrl As String) 
    Dim hWnd As Long
    Dim lngW as long
    lngW = ShellExecute(hWnd, vbNullString, strUrl, vbNullString, _
                    vbNullString, vbNormalFocus)
End Sub
 
Whoa - I am fairly new to programming in VB and I don't know a ton about HTML, so I am a little confused about your code. Would I copy what you wrote exactly, or what parts do I need to change to meet my own needs?? Where in the code is the URL?? Normally when I look at code I can figure it out, but I really need some more help here. Thanks.
 
There is no HTML.
What I gave you is a VBA module. You will have to figure out where to put it in your VBA code.I don't know anything about creating a toolbar button for your particular application. When my users press the TCLOOK button in my VB app to get to the Employee Directory on the intranet, the code in the click event calls the NAVIGATE SUB to start up the browser ("fire and forget").
Code:
Sub TCLOOK_CLICK()
    Call Navigate("http:\\10.250.2.51\tclook")
End Sub
I package NAVIGATE separately so I can use it anywhere.
 
Thank-you! Solves http association problem under win2k/xp.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top