06. december 2001 - 20:15Der er
13 kommentarer og 1 løsning
Shell (Forkert sti = fejl og luk ned)
Hvordan gør man så der ikke kommer en fejl ved f.eks hvis man skrive shell (\"noteLad.exe\") svarer den filen blev ikke fundet... og lukker ned, hvodan gør man så der f.eks bare kommer en msgbox og siger \"Forkert Filnavn/Sti???\"
Dim koer As String koer = InputBox(\"Enter Location To a Program It_ MUST Be 100% correct before the program can run_ it\", \"Kør\") Shellexec koer, vbNormalFocus
Public Declare Sub Sleep Lib \"kernel32\" (ByVal dwMilliseconds As Long) 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 Const SW_HIDE = 0 Public Const SW_SHOW = 5
Dim result As Integer result = ShellExecute(0, \"Open\", \"C:\\Path\\notepad.exe\", \"\", \"\", SW_SHOW)
place the declaration in a module so that all forms have access to it. Copy and paste it EXACTLY as it is then forget it (you dont need to worry about it)!
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 Const SW_HIDE = 0 Public Const SW_SHOW = 5
Then in a form you can use the following, change Path to the full path to the program you are opening.
Dim result As Integer result = ShellExecute(0, \"Open\", \"C:\\Path\\notepad.exe\", \"\", \"\", SW_SHOW)
If result < 32 Then MsgBox \"Ikke fundet ...\", vbExclamation end if
But shellexec can more than shell can. It opens the specific file, for example a .Doc file in the program which is associated with that file type, in this case Word!
thanks both of you... :) i like the kewl module... (im a nooB)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.