Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Opening Window From Vbscript

how can we open a new window from vbscript. i tries to use of javascript but i am not getting the syntax of writting it. i wrote the foll ways:


but all in vain. can anybody tell me how to do it....

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Accessing Explorer Window Properties When Opening A PowerPoint Show In IE Window

I am opening a PowerPoint Show inside an Internet Explorer window. (That is, on a simple html page, I have link to myfile.pps)

I want a VBA macro in that presentation to access properties of the IE window, for example, the url. But I can't find anything in the VBA object browser that loks liekwhat I want.

Does anyone out there know?


Issues Opening Pop Up Window In The Same Window Using Webbrowser Cntrl
I am having a problem opening the pop up window of a website in the same window of the webbrowser control.
when i navigate to the main URL after opning the pop up window, i see that some of the menu options of the main page in the window are missing. help.

Window XP Error 's Window Pop Out While Opening Excel File
I had created a button to open an excel sheet with the following code (also added the excel references):

Private Sub Command1_Click()
Dim AppExcel As Object
Dim AppWorksheet As Object
Dim AppWorkbook As Object

Set AppExcel = CreateObject("Excel.Application")
Set AppWorkbook = AppExcel.Workbooks.Open("C:ook1.xls")

AppWorkbook.Application.Visible = True

End Sub

I then make the program into EXE and run it on my PC (windowXP with microsoftXP offices) with no problem. The excel file opened.

Later I copy the EXE file into my office's PC (windowXP with microsoft office 2003) and run it, EXE file ran. But when I click on the button to open excel file, the window xp error reporting window pop out then the EXE file was closed. I checked the Windows Task Manager and found that the excel software was loaded but not visible.

Wondering what's wrong?

Problem Opening Folder With VBScript
I am haveing this problem opening folders with my VBScript. It opens system folders and installed program folders just fine. Except if it is a folder that was created by one of my own applications or a new folder that I add. I have checked permissions and properties to compare and can't find a difference. Has anyone come across this before. Also I can run make it work when I use the run program from the start menu, so it should work.


VBScript does not like spaces in the folder name.

Edited by - markof diego on 3/24/2005 9:19:30 AM

Window Popup Through Vbscript
i am developing a chat application in that i have put 2 type of users 1) ADMIN and 2)Genral user and for that i need that if a genral user logs in the admin should get a pop up that a new user has logged in .
so what so ever the convienent way suggest me ?
and possibly give me example code for this of for the code in asp,vbscript(server side)to get a pop up a variable is assigned by a new value.if u can send mail mail me at
if can help i will be greatful..

Run Vbscript Against Inactive Window
Is there anyway to run a VBScript in the background against window that stays open but doesn't have focus? Or if not can it be done in JScript? I really would like to be able do this in VBScript though. I'm sending keystrokes to an app but I would like to be able to continue working on something else on the same machine.

Controlling The Window Object With VbScript
I am using the following code snippet to confirm the user wants to close the browser window:

<HEAD><TITLE>A Simple Document></TITLE>
Sub unload()
window.event.returnValue = "Do you really want to quit?"
End Sub
<body onbeforeunload="unload()">

The code displays a message box upon closing the browser window. It works fine, however, the message box also displays when moving between links within the site. I only want it to display the message box when the user closes the browser window. Also the message box displays three lines of information for the user. I have listed the lines below:

1) The first line says: "Are you sure you want to navigate away from this page?"

2) The second line that's displayed is the message I pass to window.event.returnvalue in the unload subroutine above: "Do you really want to quit?"

3) And the third line says" "Press OK to continue or Cancel to stay on the current page."

So my question is how do I display this confirmation only when the browser window is closing and prevent the message box from displaying when the user is just navigating through links on my site. And how do I alter the text that's displayed on lines 1 and 3 of the message box. I would like to give the user a more specific message, and these lines seem to be hidden behind the window.event

Find An Active Window Of Access Application Using VBScript
Hello all!

I'm using an Access database both for production and testing purposes. Some time ago I've created a UserForm, which launches macro in previosly defined time, using form_timer event. Thus, if I want to add new functionality to the database, I have to close this form as it is impossible to write a new code and after all changes have been made, I have to not forget to run this form again

To optimize this I've decided to write a VBScript, doing following:
1. Looks for a Microsoft Access window. If there are no MSAccess windows, create a new one and open desired database.
2. Run the macro.

The problem I've currently stucked at is finding an Access Window using VBScript and assigining this process to a variable to be able to operate with it further. Tried some code found in internet, but it seems that VBScript does not support 'Declare Function' statement (throws out an error in the first line). Unfortunately my knowledge about API are very small

Any help would be greatly appreciated!

Opening A Window
Hey Folks,

Does anybody out there in VB land know how I can open up a folder to show the user the files that I am saving to it as they are being saved (and for that matter, how do I close the window after the last file has been saved)?

A friend told me that I can execute the Explorer.exe with the Shell function (with which I have little understanding), but I can't seem to get the right syntax...

Here's what I have:

E = Shell("C:WindowsExplorer.exe" "C:WindowsDesktopAcknowledgements")

If you know the correct syntax, or if you know a better way to do this, please let me know...




Opening New Window
How do I go about on opening up a new window within a main form. For Example: "[main form here] = [Window1] + [window 2] + [window 3]" Like a window within a window. Like in a text editor. You have the main functions form with Window1 , 2, 3, 4, 5, etc. How do you do that? The wizard that came with VB6 is on the brink and wont run. So i would appreciate help on this matter. Thanks

Opening A Window Just Once?
I have a simple form e.g. Hello World.
When I run the exe the window opens.
If I run the exe again another window opens.
How can I set it up so that if the window is already open, running the exe won't open another window?

Opening A New Window...
My friend and I are making a web browser, and we need to know the code for opening a new window.


Opening A Dos Window
how can i open a dos window and run in its command line a command that will run an application?
thnaks in advance

Opening A Window?
Im currently using the appactivate function to activate a window based on its text. The problem with this is that it only highlites it. I need it to actually open. Is there a way this can be done?>

Opening URL In A New Window?
I have this in a module:

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
Public Function OpenURL(ByVal URL As String) As Long
OpenURL = ShellExecute(0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus)

This code opens a URL perfectly but I want a code for opening a URL in a new window.
Any suggestions?

Window Opening
Dear All,

How to open a window on top of another window without setting mdi child property to true.

My problem is I have created a mdi window and many other child windows. From one of the child window when i try to open another window, it takes default setting. I do not want that window to take the default setting. Is it possible ?

Thank u all whoever has replied me for my earlier queries.


Opening A Window Into An Other Specified Window

Could you please tell me how to load or show a window(e.g. a Form, a Data report Preview,...) in to an other specified window?(Don't use MDIform)

For more detail, I am creating a form with a splitter that seperate the form to two parts. I want when a user clicks on the button in the top part. A Data report will be loaded into the bottom part. How to do this? I tried to do this but the report only was opened in a separate window. Please help me.

Thank you very much,

Trung Luu

Opening A New Browser Window
If you've used the ShellExecute API to open a webpage in the default browser, and your default browser is Internet Explorer, you notice that no matter what you do, it won't open into a new browser window. The following code is something I wrote a while back to illustrate how to overcome this by reading the registry value of the default web browser and Shelling to it.

Also, I've wrapped up my registry functions into their own functions (QueryValue and QueryValueEx) so if you want to reuse them into your own projects, be my guest. However, you will need to add support for the other types, as the QueryValueEx only has the REG_SZ support. To add support, just add another Case.

Option Explicit

Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" _
(ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, _
ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
Private Declare Function RegQueryValueExString Lib "advapi32.dll" Alias _
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As _
String, ByVal lpReserved As Long, lpType As Long, ByVal lpData _
As String, lpcbData As Long) As Long
Private Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias _
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As _
String, ByVal lpReserved As Long, lpType As Long, ByVal lpData _
As Long, lpcbData As Long) As Long

'Registry constants
Const KEY_READ = &H20019
Const REG_SZ = 1

'Error Constants
Const ERROR_NONE = 0

'Top-level key constants
'**** PASS THESE TO QUERYVALUEEX (if you decide to reuse them) ****
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000005
Const HKEY_DYN_DATA = &H80000006

Private Sub Command1_Click()
'Opens it in a brand new browser window!
OpenBrowser ""
End Sub

Function OpenBrowser(sURL As String) As Boolean
Dim sValue As String
Dim retval As Long

'Query the regkey for the default browser path
sValue = QueryValue(HKEY_CLASSES_ROOT, "httpshellopencommand", "")
'Open up the browser
retval = Shell(sValue & " " & sURL, vbNormalFocus)

'Set the return values, so we can pass it as a boolean
If retval = 0 Then
OpenBrowser = False
OpenBrowser = True
End If
End Function

Private Function QueryValue(hKeyLocation As Long, sKeyName As String, sValueName _
As String) As String
Dim lRetVal As Long
Dim hKey As Long
Dim vValue As Variant 'Be explicit with all types, even *shudder* variants

'Open up the key passed
lRetVal = RegOpenKeyEx(hKeyLocation, sKeyName, 0, _

'Query the name of the opened key
lRetVal = QueryValueEx(hKey, sValueName, vValue)

'return the value that we get from the key
QueryValue = vValue

'close the key
RegCloseKey hKey
End Function

Function QueryValueEx(ByVal lhKey As Long, ByVal szValueName As String, _
vValue As Variant) As Long
Dim cch As Long
Dim lrc As Long
Dim lType As Long
Dim lValue As Long
Dim sValue As String

On Error GoTo QueryValueExError

' Determine the size and type of data to be read
lrc = RegQueryValueExNULL(lhKey, szValueName, 0&, lType, 0&, cch)
If lrc <> ERROR_NONE Then Err.Raise 5

Select Case lType
' For strings
Case REG_SZ:
'Prebuffer the string to the required length
sValue = String$(cch, 0)

lrc = RegQueryValueExString(lhKey, szValueName, 0&, lType, _
sValue, cch)

If lrc = ERROR_NONE Then
vValue = Left$(sValue, cch - 1)
vValue = Empty
End If

Case Else
'This is for other values

End Select

QueryValueEx = lrc
Exit Function

Resume QueryValueExExit
End Function

Opening Browser Window

I've managed to open a browser window using:

but the problem is, if there is a browser window open it just redirects it, i want it to open a new instance on every call.

is this possible?

Opening A New Window With Same Form
I am attempting to get a graphing routine to work. It plots well, but if I attempt to send a second set of data to the screen to plot, while leaving an old plot on the screen, it plots the new data on top of the old.

I'd like to be able to leave the old window with the old graph on the screen, and open a new window for the new graph. This requires using the same form in two windows. Is there some way that I can add a line of code to get the graphing form to show up in a new window each time I call the graphing function that in turn plots the data on the graphing form?

At present I simply send the data to the form via a function associated with that form, then use the "show formname" command to display the form.

Thank you.

Opening An Explorer In A New Window
Hello, i am building a little program, and in my program the user choose a certain directory on the network, and i want to open this folder in a new window, as if the user entered the path on the start-run line to see what the folder contains...

If anyone can help me with this please
Thank you

Opening The Same Form In A New Window
how do I open the same form onto a new window and close the existing form...???

Opening A DOS Window On A VB5 Form
Is there a way i can open a DOS prompt inside a VB Form?

And if there is how can it be done?

Thanks anyway

Opening A Window On Top Of All Other +1 More Problem
I have a program that i want to open on top of every other program... And i want it to stay on top of the other programs...
How do i do this???

Opening A Window Inside Another
I want to launch a program inside the Internet Explorer window. So it would be inside the main "frame" of Internet Explorer. I can tell this would mean API, but which? Tried searching on but nothings jumped out at me.

Opening And Closing Window
hi, i was wondering is there a way to open My Computer in an event.

ie. when i click on a cmdButton, then, it'll open up My Computer, if i click on cmdCancel, then My Computer will be closed.

If there is a way to do that, can you please clearly explain to me how to get it to work, thank you very much

Help Opening An IE Window With Parameters
Hey Everyone (first time poster here)

Some Background: I've been working on a project that integrates a button in Outlook at and reads the subject line, parses out looking for certain words, and based on these words combs through the database looking for the folderID based on a Service Request number (always supplied in the email header) Once I find this FolderID, I am able to construct a URL and open a window. This is where I encounter my problem.

I was originally using the command:
Process.Start("IExplore.exe", FinalURL)
This works fine opening the URL, but it includes all the toolbars, navigation menu, etc.

After searching I found how to dim IE as an object of type SHDocvW.InternetExplorer, and I have turned off some of the bars:

Dim ie As New SHDocVw.InternetExplorer
ie.AddressBar = False
ie.MenuBar = False
ie.StatusBar = False
'<--this is what i cant figure out, or if this is what i should do -->
'<--it is what i found about turning on Google/Yahoo toolbars-->
'ie.ShowBrowserBar({not sure of CID}, 0, 0 )

ie.Visible = True

Again, this works fine, with the exception that I still see the Favorites, Home, Print etc. buttons at the top of my page. This is what I want to get rid of. Does anyone know how to open the window with absolutely no type of navigation at all? Also, "kiosk" mode will not work because it is full screen. Is there any way to run it in windowed mode? I would like to run the equivalent of this jscript(size does not need to be set, i just using example):,'myWindow','width=800, height=600, resizable=no, toolbar=no, location=no, menubar=no')

Thanks for your help in advance. I've looked around alot (and found quite a few ideas to make advancement to my project) but after not being able to find my answer i'd thought i'd post my question.

I think one issue is not knowing the CSLid of the Command Bar, but doesn't this ID change for every install? I've checked both my local (xp) machine and VM's (server 2003) and realized that they're completely different registry keys, so obviously setting this value will not work when I distribute it to other users. Please let me know if i'm going down the right track, if you need more information, or if im doing this wrong...

Opening A Folder In A New Window In Vb
Is there a way to open a specific folder in windows explorer with visual basic??

Opening Folder Window
I am creating a folder n opening it, in a windows explorer window.

Public FSA as FileSystemObject

Dim fiolderObj as Object
Set folderObj = FSO.GetFolder(app.path & "/myFolder")

shellexecute 0 & , vbNullString, folderObj, vbNullString, vbNullString, vbMaximiseFocus


But I do not want the Address Bar and the Standard ToolBar.

HOW can I use the property of the this opened folder, so that I can disable the Address Bar and the Standard ToolBar


Opening Browser Window From VB App.

I have a links manager program and I can get it to open up default browser when link is clicked but I want to have it open a new window for next link and not simply open same window. Can this be done with VB 6?

So far I have not had much luck.



Opening Web Page In A New Window
I have the code to open a web page when a button is clicked, but it just changes the current IE window. How do I modify this code to open the page in a new window?

VB Code:
Option ExplicitPrivate 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 Const SW_SHOWNORMAL As Long = 1Private Const SW_SHOWMINIMIZED As Long = 2Private Const SW_SHOWMAXIMIZED As Long = 3

and the button code:

VB Code:
Private Sub cmdCRKC_Click()ShellExecute Me.hwnd, "Open", "http://localhost/indexCRKCG1_G2.asp", vbNullString, "C:", SW_SHOWNORMALEnd Sub

Opening Explorer Window
I am using the below code to open an explorer window. I would like to remove the toolbar and URL bar. Also when the button is clicked the explorer window is always minimized. Is there a way to fix that.

Private sub command1_click()
Shell ("C:Program FilesInternet ExplorerIEXPLORE.EXE
end sub

Opening An Explorer Window Using VB?
Hi all,

I am trying to open an explorer window using a variable in VB and the "Start" method, but no matter what I type, it comes up with "File not found".

I have tried with " and without, but to no avail. Anyone know how to do this? I am using the shell command at the moment...



VB Code:
Dim RetVal As IntegerDim WhatToRun As String sDrive = "c: emp"WhatToRun = "Start. " & sDriveRetVal = Shell(WhatToRun, vbNormalFocus)

Opening A New Web-page Window
Hi everybody,

I got this 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 Command1_Click()
ShellExecute 0&, vbNullString, "", vbNullString, "C:", 1
End Sub

and it works, but it replaces my last web-browser window, and I want to let it open in a new window...


and while your reading this: how do you rename a file using vb?

Opening A Browser Window From Vb
I want to open a URL by click of a command button.A click of button in visual basic should open website in a browser window.How??

AxWebBrowser New Window Only Opening Once

I am having some issues with the AxWebBrowser control. In order to prevent the session state from the browser being lost when opening a popup, I am using the following code:


Public Class Browser
Private Sub AxWebBrowser_NewWindow3(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NewWindow3Event) Handles AxWebBrowser.NewWindow3
Dim popup As New Browser

e.ppDisp = popup.AxWebBrowser.Application
popup.Visible = True
End Sub
End Class

This works fine, as the session state is being transfered, however, opening a new window is only possible once. When I click a link that opens a new window (popup), the popup is being displayed properly. When I close the opened popup, and click the same link, or a new link, the popup will not open, but instead an Internet Explorer script error will be displayed that says "access denied".

My environment:

- Visual Basic 2008 Express edition
- Testing platform: Windows Vista, Windows XP

Any help would be sincerely appreciated.

Best regards,


Opening A New Window With Web Controls
I have a new custom browser and am using Microsoft Web Controls and I am wondering that if the user right clicks the page and selects open in new window, how can I get it to open in my browser form?

Words of Wisdom:
"The Internet is on Computers now!"
- Homer Simpson

Opening An IE Window Using A Hotkey.
Hi guys!
As you see I'm new to the forum. I know some coding in QBASIC, PASCAL, VB 6, VB C++ but my knowledge is quite limited. I'm going to study C++ in a year but right now I'm more comfortable with VB. Alright, enough small talk

What I want to do today is basicly a program to help me because I am so **** lazy. I want to write a program which runs in the background so whenever I press, for example, F2 a new IE windows opens and goes to a specific URL which I've predecided.

The thing is I don't quite know how to "bind" F2 to open an IE window. In fact I don't know how to open an IE window either - or set it to a specific URL.

Thanks in advance,


[This is a repost of a thread I accidently posted in the wrong forum]

Opening Folder Properties Window
I'm trying to find a way to when I click a button in my program open up the properties window of a folder/directory I specify. It would be ideal if it was on the security tab but not necessary. This is on a windows XP or an NT based system.


Browser Window Opening And Resizing
I'm a total novice when it comes to VB as the following basic query will attest to.

I use the following to open a new browser window in IE:

objHelpWin =, "newWin", "width=" & myXValue & ",height=" & myYValue & ",top=20,left=20")

As you can see I'm opening a new window and also passing the size I want it set to (for displaying an image in the newly opened window without embedding it in a htm page).

My problem is that once a new window is open subsequent calls of the same code from the parent window do not resize the spawned window or create another window but place the next image inside the existing window.

Is there any command or way I can cause an additional window to open, auto-close the existing window or even tell the existing window to resize (or is what I am asking just not possible)?

Any help will be much appreciated even if it's just a pointer as to what I can do (although I know it's probably extremely basic stuff for those of you on this forum).


Question On Opening A Browser Window
How do I open up a browser window to a web page if the user clicks on something?

Question About Opening An Email Window From VB
I have never done this before and was hoping someone could point me in the right direction...

How do I code an object in Visual Basic to open the 'compose' window of the user's email program when they click on the object, and also include the email address that I would like them to send to in the "To:" field of their email program's compose form.

Basically, I am using a label with an email address as the caption, and when the user clicks on the label, I want their email program to open a "new mail" window or "compose" window and I want it to already have the email address in the "To:" field.

I'd appreciate any help!

Minimize Access Window On Opening
How can I minimize the access window when my application starts. I would like to simply see the form that I have set to open when the application starts.


Opening Internet In A Minimized Window HELP
I am trying to make a command button that opens internet explorer on a certain URL and when it opens i want it to be minimized. I have tried a bunch of different ways, but i must be doing something wrong, here is what i have so far and it opens the web page, but it is not minimized.


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 String) As Long

Private Sub cmdint_Click()
ShellExecute Me.hwnd, vbNullString, "", vbNullString,
End Sub
Also, i want to know how to refresh the web page w/ it being minimized through my program.

Please help me.

Opening Other Apps In Different Window Sizes.
Basically I want to create a launcher that contains a few buttons, each button representing a different window size. When the button is clicked, I want the form to be able to open any .exe file in the corresponding window size of the button that is clicked. (i.e. button that says "800x600" will open any selected .exe file in that window size.)
If this is possible, could somebody create a demo project for me?
Pretty pleaseeee (i'll be your best friend and stuff :P).


Hard One Need Help Opening A Pop Up Window In Webbrowser2
Is it posable to open a pop up window that is open webbrowser1 by click a button into webbrowser2? here my code
VB Code:
Dim HTMLI As HTMLInputElement        Dim HTML As HTMLDocument        Set HTML = WebBrowser1.Document        Debug.Print HTML.documentElement.innerText        If InStr(HTML.documentElement.innerText, "One or more fields are missing or incorrect") Then Exit Sub              For Each HTMLI In HTML.getElementsByTagName("IMG")                 If HTMLI.Title = "Edit HTML Source" Then              HTMLI.Click ' this click open a new window to enter html in your     add I need it to open I webbrowser2                                 End If                Next

here the url of the site it the add html button in the body of your add part.

Opening Web Link With Window Options
** new to vb

Hi guys,

Hope you can help me out with a little problem...

I have a form and a command button....When the user presses the command button, I would like it to launch a link:

but.... I would like this window to open up with specific width and dimensions and no other words similar to a popup....

after pressing the command button, then i wish for the whole vb program to exit and end.

could anyone kindly help me out - the browser will be Internet Explorer only!

I know that I will have to insert the code into the command button click event...

thank you

Opening An Messenger Chat Window
Hi folks,

I've asked this before but not had much luck so thought I would try again.

In simple terms: I want my VB app to open a Windows/MSN Messenger chat window to a particular user (hardcoded).

If Windows/MSN Messenger isn't installed, it should throw up an error.

If the hardcoded user isn't in their contact list, it should throw up an error.

Firstly, is this possible? If not, then I should not bother going any further!

Secondly, any ideas where I could look for more information on this - there seems very little stuff out there.

Thanks in advance.


Opening URLs In New Browser Window
I have subclassed a RichTextBox to open URLs. Well, it does open up a browser (and with the code below it opens in a new browser window), but atleast Mozilla Firebird doesn't open the given url, only itself and the default homepage. Does the code below work for anyone?

VB Code:
Private Const CREATE_NEW_CONSOLE As Long = &H10Private Const NORMAL_PRIORITY_CLASS As Long = &H20Private Const INFINITE As Long = -1Private Const STARTF_USESHOWWINDOW As Long = &H1Private Const SW_SHOWNORMAL As Long = 1 Private Const MAX_PATH As Long = 260Private Const ERROR_FILE_NO_ASSOCIATION As Long = 31Private Const ERROR_FILE_NOT_FOUND As Long = 2Private Const ERROR_PATH_NOT_FOUND As Long = 3Private Const ERROR_FILE_SUCCESS As Long = 32 'my constantPrivate Const ERROR_BAD_FORMAT As Long = 11 Private Type STARTUPINFO  cb As Long  lpReserved As String  lpDesktop As String  lpTitle As String  dwX As Long  dwY As Long  dwXSize As Long  dwYSize As Long  dwXCountChars As Long  dwYCountChars As Long  dwFillAttribute As Long  dwFlags As Long  wShowWindow As Integer  cbReserved2 As Integer  lpReserved2 As Long  hStdInput As Long  hStdOutput As Long  hStdError As LongEnd Type Private Type PROCESS_INFORMATION  hProcess As Long  hThread As Long  dwProcessId As Long  dwThreadID As LongEnd Type Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpAppName As String, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As LongPrivate Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As LongPrivate Declare Function FindExecutable Lib "shell32" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal sResult As String) As LongPrivate Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nSize As Long, ByVal lpBuffer As String) As Long Private Function StartNewBrowser(sURL As String) As Boolean    Dim success As Long    Dim hProcess As Long    Dim sBrowser As String    Dim start As STARTUPINFO    Dim proc As PROCESS_INFORMATION    sBrowser = GetBrowserName(success)    If success >= ERROR_FILE_SUCCESS Then        With start            .cb = Len(start)            .dwFlags = STARTF_USESHOWWINDOW            .wShowWindow = SW_SHOWNORMAL        End With        success = CreateProcess(sBrowser, " " & sURL, 0&, 0&, 0&, NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)        StartNewBrowser = proc.hProcess <> 0        Call CloseHandle(proc.hProcess)        Call CloseHandle(proc.hThread)    End IfEnd FunctionPrivate Function GetBrowserName(dwFlagReturned As Long) As String    Dim hFile As Long    Dim sResult As String    Dim sTempFolder As String    sTempFolder = GetTempDir()    hFile = FreeFile    Open sTempFolder & "dummy.html" For Output As #hFile    Close #hFile    sResult = Space$(MAX_PATH)    dwFlagReturned = FindExecutable("dummy.html", sTempFolder, sResult)    Kill sTempFolder & "dummy.html"    GetBrowserName = TrimNull(sResult)End FunctionPrivate Function TrimNull(Item As String)    Dim pos As Integer    pos = InStr(Item, Chr$(0))    If pos Then        TrimNull = Left$(Item, pos - 1)    Else: TrimNull = Item    End IfEnd FunctionPublic Function GetTempDir() As String    Dim tmp As String    tmp = Space$(256)    Call GetTempPath(Len(tmp), tmp)    GetTempDir = TrimNull(tmp)End Function

Code I use for RTB subclassing:

VB Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate 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 Type NMHDR    hwndFrom As Long    idfrom As Long    code As LongEnd Type Private Type NMHDR_RICHEDIT    hwndFrom As Long    wPad1 As Integer    idfrom As Integer    code As Integer    wPad2 As IntegerEnd Type Private Type CHARRANGE    cpMin As Long    cpMax As LongEnd Type Private Type TEXTRANGE    chrg As CHARRANGE    lpstrText As LongEnd Type Private Type ENLINK    NMHDR As NMHDR_RICHEDIT    msg As Integer    wPad1 As Integer    wParam As Integer    wPad2 As Integer    lParam As Integer    chrg As CHARRANGEEnd Type Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As LongPrivate Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPrivate Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Private Const GWL_WNDPROC = (-4) Private Const WM_USER = &H400Private Const WM_NOTIFY = &H4EPrivate Const WM_LBUTTONDBLCLK = &H203Private Const WM_LBUTTONDOWN = &H201Private Const WM_LBUTTONUP = &H202Private Const WM_RBUTTONDBLCLK = &H206Private Const WM_RBUTTONDOWN = &H204Private Const WM_RBUTTONUP = &H205Private Const WM_MBUTTONDBLCLK = &H209Private Const WM_MBUTTONDOWN = &H207Private Const WM_MBUTTONUP = &H208 Private Const EM_SETEVENTMASK = (WM_USER + 69)Private Const EM_GETTEXTRANGE = (WM_USER + 75)Private Const EM_AUTOURLDETECT = (WM_USER + 91)Private Const EM_EXSETSEL = (WM_USER + 55) Private Const ENM_LINK = &H4000000Private Const ENM_NONE = &H0 Private Const EN_LINK = &H70B& Private mlWndProc As Long Public Sub EnableURLs(ByVal hWndParent As Long, ByVal hWndRTB As Long)    Call SendMessage(hWndRTB, EM_AUTOURLDETECT, 1, ByVal 0)    Call SendMessage(hWndRTB, EM_SETEVENTMASK, 0&, ByVal ENM_LINK)    mlWndProc = SetWindowLong(hWndParent, GWL_WNDPROC, AddressOf SubClassedWindowProc)End SubPublic Sub DisableURLs(ByVal hWndParent As Long, ByVal hWndRTB As Long)    Call SetWindowLong(hWndParent, GWL_WNDPROC, mlWndProc)    Call SendMessage(hWndRTB, EM_AUTOURLDETECT, 0&, ByVal 0&)    Call SendMessage(hWndRTB, EM_SETEVENTMASK, 0&, ByVal ENM_NONE)End SubPrivate Function SubClassedWindowProc(ByVal hWnd As Long, ByVal nMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long    Dim tNMHDR As NMHDR    Dim tENLINK As ENLINK    Dim tTEXT As TEXTRANGE    Dim sBuffer As String    If nMsg = WM_NOTIFY Then        Call CopyMemory(tNMHDR, ByVal lParam, Len(tNMHDR))        If tNMHDR.code = EN_LINK Then            Call CopyMemory(tENLINK, ByVal lParam, Len(tENLINK))            If tENLINK.msg = WM_RBUTTONUP Then                LSet tTEXT.chrg = tENLINK.chrg                sBuffer = String(tTEXT.chrg.cpMax - tTEXT.chrg.cpMin, Chr(0))                tTEXT.lpstrText = StrPtr(sBuffer)                Call SendMessage(tNMHDR.hwndFrom, EM_GETTEXTRANGE, 0, tTEXT)                sBuffer = Replace(StrConv(sBuffer, vbUnicode), Chr(0), "")                'ShellExecute hWnd, "OPEN", sBuffer, "", "", 1                StartNewBrowser sBuffer            End If        End If    End If    SubClassedWindowProc = CallWindowProc(mlWndProc, hWnd, nMsg, wParam, lParam)End Function

Any help appreciated

Copyright 2005-08, All rights reserved