469,351 Members | 1,814 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,351 developers. It's quick & easy.

Execute other Program...

On my form, I have a field that displays the student's website. How do I
display thewebsite as a hyperlink in a textbox where the user can click on
it and Internet Explorer opens up the site?
Jul 17 '05 #1
12 7968
If that's all that's in that textbox, then the solution is simple... just
set up
a CLICK event on the textbox, that passes it's contents to a SHELLEXECUTE
API call. Over here, I have this API call pre-defined as "runfile" in a
module called "shellexec", so in this situation, I would only need to do...

Private Sub Text1_Click()
ShellExec.RunFile Text1.Text
End Sub

"Scott D. Barrish" <sb******@tampabay.rr.com> wrote in message
news:iH*****************@twister.tampabay.rr.com.. .
On my form, I have a field that displays the student's website. How do I
display thewebsite as a hyperlink in a textbox where the user can click on
it and Internet Explorer opens up the site?

Jul 17 '05 #2
Thank you for your help.

I accomplished my task with the following:

Shell("c:\program files\internet explorer\iexplore.exe " & lblLink.Caption,
vbMaximizedFocus)

Sincerely,
Scott D. Barrish
Jul 17 '05 #3
On Thu, 25 Sep 2003 04:17:43 GMT, "Scott D. Barrish"
<sb******@tampabay.rr.com> wrote:
Thank you for your help.

I accomplished my task with the following:

Shell("c:\program files\internet explorer\iexplore.exe " & lblLink.Caption,
vbMaximizedFocus)


It might be an idea to programatically find the file name and location
of the default browser

The API FindExecutable() is useful for that
Jul 17 '05 #4
I used the following code:

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

Private Sub lbl_Link_Click()
Dim r As Long
r = ShellExecute(0, "open", lbl_Link.Caption,0, 0, 1)
End Sub
"J French" <er*****@nowhere.com> wrote in message
news:3f**************@news.btclick.com...
On Thu, 25 Sep 2003 04:17:43 GMT, "Scott D. Barrish"
<sb******@tampabay.rr.com> wrote:
Thank you for your help.

I accomplished my task with the following:

Shell("c:\program files\internet explorer\iexplore.exe " & lblLink.Caption,vbMaximizedFocus)


It might be an idea to programatically find the file name and location
of the default browser

The API FindExecutable() is useful for that

Jul 17 '05 #5
On Thu, 25 Sep 2003 16:11:32 GMT, "Scott D. Barrish"
<sb******@tampabay.rr.com> wrote:
I used the following code:

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


Yes, that is fine - provided one small thing ....

That you are sure that ShellExecute will recognize the 'file' that you
are sending it

Having to launch a browser to try to go to all sorts of dubiously
formatted web addresses, I opt for finding the App's name and then
launching it myself

That way I am sure a Browser will get launched ...

Think about it for a bit ...
- I spent some time worrying over the problem

Of course FindExecutable is fundamentally faulty, as it might launch a
DDE server - and also (stupidly) needs an existing file
- but give it c:\temp\dummy.htm and it comes back with a browser

- the other (safe) method is to ponce around in the registry looking
for the file associated with 'htm'
- having nailed that down once, I don't like using it
Jul 17 '05 #6
xyz
On Wed, 24 Sep 2003 12:00:14 GMT, "Scott D. Barrish"
<sb******@tampabay.rr.com> wrote:
On my form, I have a field that displays the student's website. How do I
display thewebsite as a hyperlink in a textbox where the user can click on
it and Internet Explorer opens up the site?


====================
I recently had to solve this problem. It is different for Windows
95,98,ME and Windows NT,2000,XP. Here is a cross-system solution.

Place a "Microsoft SysInfo control" on your form. Set the "label"
field that displays the web site URL to be underlined in the Font
attribute, set the MousePointer attribute to 99 (custom), and set the
MouseIcon to HAND-M.CUR (it is normally in the /windows/cursors
directory, I attached it). This will cause the web hand to show when
the cursor is placed over the label that has the web link.
' The declaration below goes in a Module1.bas file
' execute shell command
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
' This is the code to launch the browser (It assumes that
' the form with the SysInfo control is frmMain
Private Sub Label5_Click()

Dim rcu As Long
Dim URL As String
' ShellExecute defined in Module1.bas

URL = "http://www.yahoo.com/" ' or whatever

If frmMain.SysInfo1.OSPlatform = 2 Then
' OSPlatform = 2 for Win NT/2000/XP
Call ShellExecute(Me.hwnd, "open", URL, "", "", 0)
Else
' OSPlatform = 1 for Win 95/98/ME
rcu = Shell("start " & URL, vbNormalFocus)
End If
End Sub


Jul 17 '05 #7
xyz


Jul 17 '05 #8
Iexplorer.exe is not the only browser out there.

I think one should try to locate the browser associated with the htm files,
as you say. However I dont I dont know how :-)

A.

"J French" <er*****@nowhere.com> wrote in message
news:3f**************@news.btclick.com...
On Thu, 25 Sep 2003 16:11:32 GMT, "Scott D. Barrish"
<sb******@tampabay.rr.com> wrote:
I used the following code:

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


Yes, that is fine - provided one small thing ....

That you are sure that ShellExecute will recognize the 'file' that you
are sending it

Having to launch a browser to try to go to all sorts of dubiously
formatted web addresses, I opt for finding the App's name and then
launching it myself

That way I am sure a Browser will get launched ...

Think about it for a bit ...
- I spent some time worrying over the problem

Of course FindExecutable is fundamentally faulty, as it might launch a
DDE server - and also (stupidly) needs an existing file
- but give it c:\temp\dummy.htm and it comes back with a browser

- the other (safe) method is to ponce around in the registry looking
for the file associated with 'htm'
- having nailed that down once, I don't like using it

Jul 17 '05 #9
On Fri, 26 Sep 2003 20:48:50 +0300, "Aristotelis E. Charalampakis"
<ar***********************@REMOVEMEhotmail.com> wrote:
Iexplorer.exe is not the only browser out there.

I think one should try to locate the browser associated with the htm files,
as you say. However I dont I dont know how :-)

1) ShellExecute() finds and runs the browser

2) FindExecutable() finds the browser - you need to run it (good)

3) Peer into the Registry - Ok - but can be tedious

Jul 17 '05 #10
mmm, of course you are right.

Should have checked before opening my mouth. I wasnt aware of this api, but
appleman is clear:

FindExecutable

Finds the file name of the program that is associated with a specified file.
The Windows registration editor can be used to associate types of files with
particular applications. For example, text files that have the extension
..TXT are typically associated with the Windows Notepad (NOTEPAD.EXE).

Cheers

"J French" <er*****@nowhere.com> wrote in message
news:3f***************@news.btclick.com...
On Fri, 26 Sep 2003 20:48:50 +0300, "Aristotelis E. Charalampakis"
<ar***********************@REMOVEMEhotmail.com> wrote:
Iexplorer.exe is not the only browser out there.

I think one should try to locate the browser associated with the htm files,as you say. However I dont I dont know how :-)

1) ShellExecute() finds and runs the browser

2) FindExecutable() finds the browser - you need to run it (good)

3) Peer into the Registry - Ok - but can be tedious

Jul 17 '05 #11
On Sat, 27 Sep 2003 09:21:58 +0300, "Aristotelis E. Charalampakis"
<ar***********************@REMOVEMEhotmail.com> wrote:
mmm, of course you are right.

Should have checked before opening my mouth. I wasnt aware of this api, but
appleman is clear:

FindExecutable

Finds the file name of the program that is associated with a specified file.
The Windows registration editor can be used to associate types of files with
particular applications. For example, text files that have the extension
.TXT are typically associated with the Windows Notepad (NOTEPAD.EXE).


The only 'gotcha' is that you have to give it the name of a file that
actually exists.

So if I want to go to 'www.borland.com'
then I create a file called : 'c:\temp\dummy.htm'

Use FindExecutable() to find the EXE for 'c:\temp\dummy.htm'
Then launch that EXE with the 'real' target in the command line

A bit silly of MS to make the file have to exist, but there are some
legacy DDE considerations that I've chosen to ignore.
Jul 17 '05 #12
On Sat, 27 Sep 2003 09:21:58 +0300, "Aristotelis E. Charalampakis"
<ar***********************@REMOVEMEhotmail.com> wrote:
mmm, of course you are right.

Should have checked before opening my mouth. I wasnt aware of this api, but
appleman is clear:

Dunno, by asking you've found something fairly obscure ...

Oops - I meant to post this

This link might also be useful :-

Obtaining the Path and Filename of the Default Browser
http://www.mvps.org/vbnet/code/filea...erfilename.htm
Jul 17 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Thomas | last post: by
4 posts views Thread by Chris | last post: by
reply views Thread by wolf2300 | last post: by
3 posts views Thread by =?Utf-8?B?S3VlaXNoaW9uZyBUdQ==?= | last post: by
6 posts views Thread by moongeegee | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.