Solved

putting url link on a form

Posted on 1998-07-11
8
155 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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 50 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

719 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