?
Solved

putting url link on a form

Posted on 1998-07-11
8
Medium Priority
?
156 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 1

Expert Comment

by:Jason_G
ID: 1465505
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
ID: 1465506
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
ID: 1465507
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Glynn071198
ID: 1465508
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
 

Author Comment

by:Glynn071198
ID: 1465509
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
ID: 1465510
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 200 total points
ID: 1465511
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
ID: 1465512
works great thanks
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

800 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