VB 6.0 y llamar pagina Html
Hola...
Como puedo llamar desde Visual una pagina html?
como por ejemplo cuando llamamos un documento en word.
que objeto debo crear? que debo hacer?
Como puedo llamar desde Visual una pagina html?
como por ejemplo cuando llamamos un documento en word.
que objeto debo crear? que debo hacer?
Te pongo un ejemplo que viene en la MSDN library:
Private Const SW_SHOW = 5 ' Displays Window in its current size
' and position
Private Const SW_SHOWNORMAL = 1 ' Restores Window if Minimized or
' Maximized
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 Declare Function FindExecutable Lib "shell32.dll" Alias _
"FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As _
String, ByVal lpResult As String) As Long
Private Sub Command1_Click()
Dim FileName, Dummy As String
Dim BrowserExec As String * 255
Dim RetVal As Long
Dim FileNumber As Integer
' First, create a known, temporary HTML file
BrowserExec = Space(255)
FileName = "C:temphtm.HTM"
FileNumber = FreeFile ' Get unused file number
Open FileName For Output As #FileNumber ' Create temp HTML file
Write #FileNumber, "<HTML> <HTML>" ' Output text
Close #FileNumber ' Close file
' Then find the application associated with it
RetVal = FindExecutable(FileName, Dummy, BrowserExec)
BrowserExec = Trim(BrowserExec)
' If an application is found, launch it!
If RetVal <= 32 Or IsEmpty(BrowserExec) Then ' Error
MsgBox "Could not find associated Browser", vbExclamation, _
"Browser Not Found"
Else
RetVal = ShellExecute(Me.hwnd, "open", BrowserExec, _
"www.microsoft.com", Dummy, SW_SHOWNORMAL)
If RetVal <= 32 Then ' Error
MsgBox "Web Page not Opened", vbExclamation, "URL Failed"
End If
End If
Kill FileName ' delete temp HTML file
End Sub
Private Const SW_SHOW = 5 ' Displays Window in its current size
' and position
Private Const SW_SHOWNORMAL = 1 ' Restores Window if Minimized or
' Maximized
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 Declare Function FindExecutable Lib "shell32.dll" Alias _
"FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As _
String, ByVal lpResult As String) As Long
Private Sub Command1_Click()
Dim FileName, Dummy As String
Dim BrowserExec As String * 255
Dim RetVal As Long
Dim FileNumber As Integer
' First, create a known, temporary HTML file
BrowserExec = Space(255)
FileName = "C:temphtm.HTM"
FileNumber = FreeFile ' Get unused file number
Open FileName For Output As #FileNumber ' Create temp HTML file
Write #FileNumber, "<HTML> <HTML>" ' Output text
Close #FileNumber ' Close file
' Then find the application associated with it
RetVal = FindExecutable(FileName, Dummy, BrowserExec)
BrowserExec = Trim(BrowserExec)
' If an application is found, launch it!
If RetVal <= 32 Or IsEmpty(BrowserExec) Then ' Error
MsgBox "Could not find associated Browser", vbExclamation, _
"Browser Not Found"
Else
RetVal = ShellExecute(Me.hwnd, "open", BrowserExec, _
"www.microsoft.com", Dummy, SW_SHOWNORMAL)
If RetVal <= 32 Then ' Error
MsgBox "Web Page not Opened", vbExclamation, "URL Failed"
End If
End If
Kill FileName ' delete temp HTML file
End Sub
Me parece que yo tengo una solución un poquillo más fácil que la que te han dado:
Private Sub AbrirHTM()
Dim ie As Object
Dim ruta As String
ruta = "Aquí escribes la ruta completa de la página"
Set ie = CreateObject("InternetExplorer.Application")
ie.Application.Visible = True
'Abres el documento
ie.Navigate (ruta)
End Sub
Espero que te sirva
Un saludo
sdemingo
Private Sub AbrirHTM()
Dim ie As Object
Dim ruta As String
ruta = "Aquí escribes la ruta completa de la página"
Set ie = CreateObject("InternetExplorer.Application")
ie.Application.Visible = True
'Abres el documento
ie.Navigate (ruta)
End Sub
Espero que te sirva
Un saludo
sdemingo
