Solved

putting url link on a form

Posted on 1998-07-11
8
149 Views
Last Modified: 2010-05-03
how can i put url link on a form or command button
to my homepage
0
Comment
Question by:Glynn071198
8 Comments
 
LVL 1

Expert Comment

by:Jason_G
Comment Utility
Hi Glynn,
I believe what you are looking for here is the Hyperlink object.  Using the properties and methods of the Hyperlink object, your ActiveX document or ActiveX control can request a hyperlink-aware container, such as Microsoft Internet Explorer, to jump to a given URL.

You can use the NavigateTo method to jump to a URL. For example, the following code presumes an ActiveX document named "axdMyDoc" exists:
UserDocument.Hyperlink.NavigateTo _
"c:\mydocs\axdmydoc.vbd"
      
If your ActiveX document is contained by a hyperlink-aware container (such as Internet Explorer), and if the container maintains a history of documents, use the GoBack or GoForward methods to go backwards or forwards through the list. However, be sure to use error-checking, as shown in the example below:
Private Sub cmdGoForward_Click()
      On Error GoTo noDocInHistory
      UserDocument.Hyperlink.GoForward
      Exit Sub
noDocInHistory:
      Resume Next
End Sub

The syntax for using the NavigateTo method is as follows.

object.NavigateTo Target [, Location [, FrameName]]

The NavigateTo method syntax has these parts:

Part - Description

object - An object expression that evaluates to an object in the Applies To list.

Target - A string expression specifying the location to jump to. This can be a document or a URL.

Location - A string expression specifying the location within the URL specified in Target to jump to. If Location is not specified, the default document will be jumped to.

FrameName - A string expression specifying the frame within the URL specified in Target to jump to. If FrameName is not specified, the default frame will be jumped to.

Also, if the object is in a container that supports OLE hyperlinking, then the container will jump to the specified location. If the object is in a container that does not support OLE hyperlinking, then an application that is registered as supporting hyperlinking is started to handle the request.
If Target does not specify a valid location, an error is raised.

I hope this helps you.

Sincerely,
Jason

Jason Gorman (jason_gorman@scholars.com)
Learning Advisor, scholars.com
Microsoft Authorized Technical Education Center
Novell Authorized Online Training Provider
http://scholars.com
0
 

Author Comment

by:Glynn071198
Comment Utility
thanks jason for for your help but im just a beginer and you lost me when you got to activeX controls. is there a simpler way? i really need some sample code to study. any suggestions on where i might find info.

0
 
LVL 2

Expert Comment

by:rayb
Comment Utility
Here's an easy method:

In your forms declarations add this:
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

Place a label on a form.
In the OnClick handler for the label, put something like this:
nResult= ShellExecute( null, "open", "http://www.yourlink.com", "", "", 5)

0
 

Author Comment

by:Glynn071198
Comment Utility
dear rayb,
tryed pasting code in declaration and got this error:
(Constants, fixed length strings, arrays and declare statments
not allowed as public members of class or form modules.)
did i do something wrong?

ps, would like to run commamd from button or in menu
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:Glynn071198
Comment Utility
found something that works using the start.exe in windows\command directory

nResult = Shell("start.exe http://www.nascar.com", vbHide)

if you find something else let me know thanks
0
 
LVL 4

Expert Comment

by:tomook
Comment Utility
You will have better luck with ShellExecute in the long run, and the Hyperlink object in the longer run. As to ShellExecute, "Public Declares" are allowed only in regular modules. Put the declaration in a regular module or declare it "Private" in your form. Maybe Jason_G could give you some help on installing the Hyperlink control.
0
 
LVL 1

Accepted Solution

by:
movieguy earned 50 total points
Comment Utility
In your project add the following to a module

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


Where every you want the action to take place like when you choose a menu or click a button add the following.

Call ShellExecute(Me.hWnd, "open", "http://www.address.com", "", "", 5)

I have used this code in menus, buttons, and in label click events and it works in vb5.

0
 

Author Comment

by:Glynn071198
Comment Utility
works great thanks
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now