Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[blue]Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Const PROCESS_TERMINATE = &H1
Public Function KillProcess(pid As Long) As Long
Dim hProcess As Long
hProcess = OpenProcess(PROCESS_TERMINATE, 0, pid)
If hProcess Then
KillProcess = TerminateProcess(hProcess, 1&)
CloseHandle hProcess
End If
End Function[/blue]
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 UserForm_Initialize()
Me.Caption = StrConv(strFileType, vbUpperCase) & " file listing within the " & StrConv(strDirectory, vbUpperCase) & " directory"
With Application.FileSearch
.NewSearch
.LookIn = strDirectory
.SearchSubFolders = False
.Filename = "*." & strFileType
.MatchTextExactly = False
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Dim strFileName As String
If Right(.FoundFiles(i), 3) = strFileType Then
strFileName = Mid(.FoundFiles(i), Len(strDirectory) + 1, Len(.FoundFiles(i)) - (Len(strDirectory) + Len(strFileType) + 1))
Me.lstDirectoryFiles.AddItem strFileName
End If
Next i
End If
End With
End Sub
Private Sub cmdPrint_Click()
Dim strURL As String
strURL = strDirectory & lstDirectoryFiles & "." & strFileType
If strURL = strDirectory & "." & strFileType Then
MsgBox "You haven't selected a file to print.", vbExclamation, StrConv(strFileType, vbUpperCase) & " Open Editor"
End If
Application. ScreenUpdating = False
Call ShellExecute(0&, vbNullString, strURL, vbNullString, vbNullString, 0) 'Change 0 to vbNormalFocus to view.
PrintURL = ShellExecute(0&, "print", strURL, vbNullString, vbNullString, 0) 'Change 0 to vbNormalFocus to view.
Application.Run "CloseDefinedApp"
Application.ScreenUpdating = True
End Sub
Sub CloseDefinedApp()
'UDF from 'ClassNames' module. Change the filter string to what
'appears in the caption bar of the application opening the
'desired file type (eg "Acrobat" for *.pdf files or "Notepad" for *.txt files).
'This UDF also sets the Public Variable 'strClassNameToClose'.
fEnumWindows ("Adobe Reader")
'UDF from 'CloseApplications' module. This UDF uses the 'strClassNameToClose'
'string (see above) to know which application to close.
fCloseApp (strClassNameToClose)
End Sub
Private Const WM_CLOSE = &H10
Private Const INFINITE = &HFFFFFFFF
Private Declare Function apiPostMessage _
Lib "user32" Alias "PostMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) _
As Long
Private Declare Function apiFindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) _
As Long
Private Declare Function apiWaitForSingleObject _
Lib "kernel32" Alias "WaitForSingleObject" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) _
As Long
Private Declare Function apiIsWindow _
Lib "user32" Alias "IsWindow" _
(ByVal hWnd As Long) _
As Long
Private Declare Function apiGetWindowThreadProcessId _
Lib "user32" Alias "GetWindowThreadProcessId" _
(ByVal hWnd As Long, _
lpdwProcessID As Long) _
As Long
Function fCloseApp(lpClassName As String) As Boolean
'Usage Examples:
' To close Calculator:
' ? fCloseApp("SciCalc")
'
'
Dim lngRet As Long, hWnd As Long, pID As Long
hWnd = apiFindWindow(lpClassName, vbNullString)
If (hWnd) Then
lngRet = apiPostMessage(hWnd, WM_CLOSE, 0, ByVal 0&)
Call apiGetWindowThreadProcessId(hWnd, pID)
Call apiWaitForSingleObject(pID, INFINITE)
fCloseApp = Not (apiIsWindow(hWnd) = 0)
End If
End Function