ShellExecute only opens file.htm if browser already open 
Author Message
 ShellExecute only opens file.htm if browser already open

I use VB6 and Windows 2000.

When I double-click file.htm in Windows Explorer it opens in the
default browser (which is Internet Explorer 5).

However, when I use ShellExecute to do the same thing, it only opens
if the browser is already open in another window.

Here is my code:

Public 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 mnunewmediaviewhelp_Click()
On Error GoTo err
Dim mapp As String
Dim mfile As String
mapp = App.path
If Right(mapp, 1) <> "\" Then mapp = mapp + "\"
mfile = mapp + "help.htm"
ShellExecute Me.hwnd, "open", mfile, vbNullString, vbNullString, 3
Exit Sub
err:
MsgBox err.Description & " NewMediaView Help"
End Sub

Any help is greatly appreciated.

Sincerely,

Jan Nordgreen



Mon, 11 Jul 2005 06:39:48 GMT  
 ShellExecute only opens file.htm if browser already open
Since you try to open a htm file, you can try OpenNew verb to open a new IE
window. For example:

ShellExecute Me.hwnd, "opennew", mfile, vbNullString, vbNullString, 3

Sincerely,

Alick Ye, MCSD
Product Support Services
Microsoft Corporation
Get Secure! - <www.microsoft.com/security>

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

| Newsgroups: microsoft.public.vb.com
| Subject: ShellExecute only opens file.htm if browser already open
| Date: 22 Jan 2003 14:39:48 -0800
for-mail
| Xref: cpmsftngxa08 microsoft.public.vb.com:33331
| X-Tomcat-NG: microsoft.public.vb.com
|
| I use VB6 and Windows 2000.
|
| When I double-click file.htm in Windows Explorer it opens in the
| default browser (which is Internet Explorer 5).
|
| However, when I use ShellExecute to do the same thing, it only opens
| if the browser is already open in another window.
|
| Here is my code:
|
| Public 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 mnunewmediaviewhelp_Click()
| On Error GoTo err
| Dim mapp As String
| Dim mfile As String
| mapp = App.path
| If Right(mapp, 1) <> "\" Then mapp = mapp + "\"
| mfile = mapp + "help.htm"
| ShellExecute Me.hwnd, "open", mfile, vbNullString, vbNullString, 3
| Exit Sub
| err:
| MsgBox err.Description & " NewMediaView Help"
| End Sub
|
| Any help is greatly appreciated.
|
| Sincerely,
|
| Jan Nordgreen
|



Tue, 12 Jul 2005 11:00:09 GMT  
 ShellExecute only opens file.htm if browser already open

[This is off-topic for vb.com, as it has nothing at all to do with COM.
It's not a multipost, is it?]


Quote:
> I use VB6 and Windows 2000.

> When I double-click file.htm in Windows Explorer it opens in the
> default browser (which is Internet Explorer 5).

> However, when I use ShellExecute to do the same thing, it only opens
> if the browser is already open in another window.

> ShellExecute Me.hwnd, "open", mfile, vbNullString, vbNullString, 3

You may wish to try using SW_SHOWMAXIMIZED instead of SW_MAXIMIZE.


Wed, 13 Jul 2005 08:48:42 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. opening an htm file with default browser

2. How to open a file for read that is already open by another application

3. Open an already opened file

4. How can i block opening a form that is already open

5. Mail merge from Access try to open an already open DB

6. File not Found / File already open

7. Open a HTM/swf file from word APP using a macro

8. Opening .htm files as text in Word2000

9. I need to open an .htm file from an url

10. Opening a HTM file!

11. Shellexecute - Closing an open file in VB

12. checking if a file is already open

 

 
Powered by phpBB® Forum Software