Please tell me how to open a website ,e.g :www.vbforums.com when we click the command button on the program?
Thank you very much!!!
Printable View
Please tell me how to open a website ,e.g :www.vbforums.com when we click the command button on the program?
Thank you very much!!!
Again, this should be in the other parts of the Forums (General VB Questions).
Also, try to include all of your questions in ONE POST.
VB Code:
Shell "iexplore [url]http://www.vbforums.com[/url]", vbMaximized
Phreak
This code will ensure the website is openend in a new browser window. Only works for IE though...
VB Code:
On Error Resume Next Dim Temp As Object 'Create instance Set Temp = CreateObject("InternetExplorer.Application") 'Open URL Temp.Navigate2 "http://fox.acky.net" Temp.Visible = True
(If the code fails you could try Netscape and the others...)
This sub opens a link in the default browser. I hope it helps!
VB Code:
Private Sub openUrl(sLink As String) Dim lPath As Long Dim sPath As String Dim sTempPath As String Dim iFile As Integer If Me.Tag = "" Then If Dir(App.Path & "\Temp.htm") = vbNullString Then iFile = FreeFile Open App.Path & "\Temp.htm" For Output As iFile Close iFile Me.Tag = Left(sPath, FindExecutable(App.Path & "\Temp.htm", "", ByVal sPath)) Kill sTempPath & "Temp.htm" Else Me.Tag = Left(sPath, FindExecutable(App.Path & "\Temp.htm", "", ByVal sPath)) End If End If If Len(Me.Tag) Then ShellExecute 0, "OPEN", Me.Tag, sLink, "", 1 End If End Sub
The declarations for henrikf's code :
VB Code:
Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Long 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
Sorry, I missed those. :blush:
Don't worry about it. I just figured I'd mention them :afrog:Quote:
Originally posted by henrikf
Sorry, I missed those. :blush: