Dim WithEvents TBLfalse As VB.Line, TBL(130) As VB.Line
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 cmd_zadanie_Click()
Application.StartupPath 0, "open", "\zadanie1.html", 0, 0, 0
End Sub
Ошибка при попытке открыть браузером имеющийся файл
Код:
Выбило ошибку Variable not defined. Подскажите как исправить или написать иначе.
А где вы, собственно, вызываете ShellExecute?
А выглядит это примерно так:
Код:
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 cmd_zadanie_Click()
ShellExecute 0, "open", "zadanie1.html", 0, 0, 0
End Sub
Private Sub cmd_zadanie_Click()
ShellExecute 0, "open", "zadanie1.html", 0, 0, 0
End Sub
При чем заметьте => "zadanie1.html" указано без слеша в начале и это и есть относительный путь. В принципе можно в "" вписать полный http какой ни буть странички и она откроеться.
Мне этот слеш вылился в несколько дней поэтому вот еще 2 кода как это можно зделать:
Код:
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 cmd_zadanie_Click()
ShellExecute Me.hwnd, "open", "zadanie1.html", vbNullString, vbNullString, 1
End Sub
Private Sub cmd_zadanie_Click()
ShellExecute Me.hwnd, "open", "zadanie1.html", vbNullString, vbNullString, 1
End Sub
И
Код:
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)
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Const SW_SHOWNORMAL = 1
Private Sub cmd_zadanie_Click()
Call ShellExecute(GetDesktopWindow, "Open", _
"zadanie1.html", "", "c:\", SW_SHOWNORMAL)
End Sub
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)
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Const SW_SHOWNORMAL = 1
Private Sub cmd_zadanie_Click()
Call ShellExecute(GetDesktopWindow, "Open", _
"zadanie1.html", "", "c:\", SW_SHOWNORMAL)
End Sub
Код:
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_SHOW = 5
Private Sub Find(Optional initialDirectory As String)
ShellExecute 0, "find", IIf(InitialDirectory = "", "", InitialDirectory), vbNullString, vbNullString, SW_SHOW
End Sub
Const SW_SHOW = 5
Private Sub Find(Optional initialDirectory As String)
ShellExecute 0, "find", IIf(InitialDirectory = "", "", InitialDirectory), vbNullString, vbNullString, SW_SHOW
End Sub
Открывает стандартное окно поиска Windows Explorer'а. Если задано initialDirectory, то его значение вставляется в поле "Где искать".