|
-
May 1st, 2007, 07:10 PM
#1
Thread Starter
Addicted Member
[question] can i make a button that will open browser in new window?
as my title says,
ther is way to make a button that will open browser?
out side of the program.
if ther is how do i do it =\
-
May 1st, 2007, 07:12 PM
#2
Re: [question] can i make a button that will open browser in new window?
A particular page as well? Or just open up the browser?
-
May 1st, 2007, 07:18 PM
#3
Re: [question] can i make a button that will open browser in new window?
vb Code:
Private Sub Button1_Click()
OpenSite ("Site here")
End Sub
Public Sub OpenSite(URL As String)
ShellExecute 0&, "Open", URL, 0&, 0&, vbNormalFocus
End Sub
That is probably what you are looking for hope it helps
-
May 1st, 2007, 08:12 PM
#4
Thread Starter
Addicted Member
Re: [question] can i make a button that will open browser in new window?
 Originally Posted by Hell-Lord
vb Code:
Private Sub Button1_Click()
OpenSite ("Site here")
End Sub
Public Sub OpenSite(URL As String)
ShellExecute 0&, "Open", URL, 0&, 0&, vbNormalFocus
End Sub
That is probably what you are looking for hope it helps 
sub or function not defined =\
what the hell that means
-
May 1st, 2007, 10:17 PM
#5
Re: [question] can i make a button that will open browser in new window?
Add the ShellExecute API function declaration to the very top of your code (under Option Explicit if it's there).
vb 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
Also make sure you have a command button on the form named "Button1" when testing the code.
-
Oct 25th, 2007, 07:23 AM
#6
Re: [question] can i make a button that will open browser in new window?
Topic says can i make a button that will open browser in new window?
The ShellExecute API will just keep opening the default browser with a new URL. If you right-click on a link you can use Open in New Window. How do you get ShellExecute to open in a new window?
Lets say you have a ListBox with URL's added and everytime you click on the ListBox it opens a new window to that List1.Text (URL).
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
-
Oct 25th, 2007, 07:46 AM
#7
Frenzied Member
Re: [question] can i make a button that will open browser in new window?
-
Oct 25th, 2007, 07:54 AM
#8
Frenzied Member
Re: [question] can i make a button that will open browser in new window?
ok came with a solution
Make a reference to Microsoft Internet Controls
put this in a module
Public ie2() As InternetExplorer
in your form use like this
Code:
Private Sub Form_Load()
ReDim ie2(0)
End Sub
Private Sub Command3_Click()
ReDim Preserve ie2(UBound(ie2) + 1)
Set ie2(UBound(ie2)) = CreateObject("InternetExplorer.Application")
ie2(UBound(ie2)).Visible = True
ie2(UBound(ie2)).Navigate2 "http://www.vbforums.com/"
End Sub
-
Oct 25th, 2007, 08:04 AM
#9
Hyperactive Member
Re: [question] can i make a button that will open browser in new window?
Or you could use
vb Code:
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate "your url here"
-Show me on the doll where the music touched you.
-
Oct 25th, 2007, 10:27 AM
#10
Re: [question] can i make a button that will open browser in new window?
Thanks guys.
zeezee's link only says to reference Microsoft Internet Controls in your project, which I've done (Microsoft Internet Controls, Shdocvw.dll) but I get a Type Mismatch error here
Set ie1 = CreateObject("InternetExplorer.Application")
I've tried Dim ie1 As InternetExplorer and Dim ie1 As WebBrowser but I still get the same error.
zeezee's other example gives me the exact same error in
Set ie2(UBound(ie2)) = CreateObject("InternetExplorer.Application")
Ambivalentiowa example works for the first URL and when you click the button again the web page shows in a new window but there are no objects on the page, its a blank page.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
-
Oct 25th, 2007, 10:43 AM
#11
Re: [question] can i make a button that will open browser in new window?
Using shellexecute you can open a new browser this way.
Code:
Option Explicit
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
Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
ShellExecute Me.hwnd, "Open", "IExplore.exe", "http://www.dell.com", "C:\", SW_SHOWNORMAL
End Sub
-
Oct 25th, 2007, 10:44 AM
#12
Frenzied Member
Re: [question] can i make a button that will open browser in new window?
It should be the Reference, not the components. Its the same DLL, but it should be referenced. (I dont know why its acting like that.)
-
Oct 25th, 2007, 10:48 AM
#13
Frenzied Member
Re: [question] can i make a button that will open browser in new window?
 Originally Posted by Keithuk
Ambivalentiowa example works for the first URL and when you click the button again the web page shows in a new window but there are no objects on the page, its a blank page. 
What Ambivalentiowa has said is without using the reference , you can do my example , but you have to declare the ie2 as object.
-
Oct 25th, 2007, 01:49 PM
#14
Re: [question] can i make a button that will open browser in new window?
 Originally Posted by zeezee
It should be the Reference, not the components. Its the same DLL, but it should be referenced. (I dont know why its acting like that.)
Ok I removed the WebBroswer control and just referenced Shdocvw.dll and it worked without an error. But when I closed the IE windows it throws up a 462 error The remote server machine does not exist or is unavailable. That happens in the
Debug.Print "ie busy " & CStr(i * 0.1) & " seconds with ReadyState " & ie1.ReadyState
I've tried all of the three different way and they all work. The problem must have been the reference to Shdocvw.dll and not the control.
Thanks guys, thats a great help.
I wonder if Incures has ever been back to check on his post? His original question was can i make a button that will open browser in new window?. With him saying new window I thought he was having the same problem.
MarkT I know what ShellExecute does I've used it for years. I was wondering if you could ShellExecute a new window but it doesn't.
Thanks again for you help.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
-
Oct 25th, 2007, 02:04 PM
#15
Re: [question] can i make a button that will open browser in new window?
 Originally Posted by Keithuk
MarkT I know what ShellExecute does I've used it for years. I was wondering if you could ShellExecute a new window but it doesn't.
Thanks again for you help. 
Have you tried the code I posted? Unless I don't understand what you mean by ShellExecute a new window this should work. It doesn't reuse a currently open window.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|