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.
Option Compare Database
Option Explicit
Private Sub Form_Load()
Me.Visible = True
Me.Repaint
DoEvents
'1. identify files to delete
'2. delete files
'3. copy shortcut over to All Users directory
'4. make note of userid so that I can know who has copied their shortcut over.
'5. open new shortcut link
'6. close this database
RunShortcutUpdates
End Sub
Private Sub RunShortcutUpdates()
Dim str As String
Dim strUserDesktopShortcut As String
Dim fNT4 As Boolean
Const strShortcutFilename As String = "YOUR_SHORTCUT_FILE.LNK"
Const strSourceFilename As String = "FULL_DRIVE_AND_PATHNAME_AND_FILENAME_OF_SOURCE.LNK"
str = fOSName()
If Left(str, Len("Windows 2000")) = "Windows 2000" Then
fNT4 = False
WriteLn "Windows 2000 machine"
Else 'only other option is NT4 at this point
fNT4 = True
WriteLn "Windows NT 4 machine"
End If
'1
str = Environ("USERPROFILE") & "\Desktop\" & strShortcutFilename
strUserDesktopShortcut = str
WriteLn "File to remove is " & str
'2
If Dir(str) <> "" Then
WriteLn "Deleting file (" & str & ")..."
FileSystem.Kill str
WriteLn "Deleted"
End If
'3
WriteLn "Finding All Users directory..."
If fNT4 = True Then
str = "C:\WINNT\Profiles\All Users"
Else
'2000 machines should have all usersprofile set
str = Environ("ALLUSERSPROFILE")
'...but if it's not set, set it to this
If str = "" Then
str = "C:\Documents And Settings\All Users"
End If
End If
WriteLn "All Users dir: " & str
str = str & "\Desktop\" & strShortcutFilename
WriteLn "Copying shortcut to All Users desktop directory"
FileSystem.FileCopy strSourceFilename, str
WriteLn "Copying shortcut to user desktop"
FileSystem.FileCopy strSourceFilename, strUserDesktopShortcut
'4
WriteLn "Logging completed file transfers. User '" & Environ("USERNAME") & "' has updated shortcuts."
FileSystem.FileCopy strSourceFilename, strSourceFilename & "." & Environ("COMPUTERNAME") & "." & Environ("USERNAME") & "." & CurrentUser
'5
WriteLn "Opening the new database"
apiHandleFile str, WIN_MAX
'6
WriteLn "Closing this window"
DoCmd.Quit acQuitSaveNone
End Sub
Private Sub WriteLn(str As String)
Dim dat As Date
txt.Value = txt.Value & str & vbCrLf
dat = Now()
Me.Repaint
DoEvents
Do While (CDbl(Now()) - CDbl(dat)) * 24 * 60 * 60 < 0.4
DoEvents
Loop
End Sub
'from a different module
Option Explicit
Option Compare Database
'************ Code Start **********
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiShellExecute 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
'***App Window Constants***
Public Const WIN_NORMAL = 1 'Open Normal
Public Const WIN_MAX = 3 'Open Maximized
Public Const WIN_MIN = 2 'Open Minimized
'***Error Codes***
Private Const ERROR_SUCCESS = 32&
Private Const ERROR_NO_ASSOC = 31&
Private Const ERROR_OUT_OF_MEM = 0&
Private Const ERROR_FILE_NOT_FOUND = 2&
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&
'***************Usage Examples***********************
'Open a folder: ?fHandleFile("C:\TEMP\",WIN_NORMAL)
'Call Email app: ?fHandleFile("mailto:dash10@hotmail.com",WIN_NORMAL)
'Open URL: ?fHandleFile("[URL unfurl="true"]http://home.att.net/~dashish",[/URL] WIN_NORMAL)
'Handle Unknown extensions (call Open With Dialog):
' ?fHandleFile("C:\TEMP\TestThis",Win_Normal)
'Start Access instance:
' ?fHandleFile("I:\mdbs\CodeNStuff.mdb", Win_NORMAL)
'****************************************************
Function apiHandleFile(stFile As String, lShowHow As Long)
Dim lRet As Long, varTaskID As Variant
Dim stRet As String
'First try ShellExecute
lRet = apiShellExecute(hWndAccessApp, vbNullString, _
stFile, vbNullString, vbNullString, lShowHow)
If lRet > ERROR_SUCCESS Then
stRet = vbNullString
lRet = -1
Else
Select Case lRet
Case ERROR_NO_ASSOC:
'Try the OpenWith dialog
varTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " _
& stFile, WIN_NORMAL)
lRet = (varTaskID <> 0)
Case ERROR_OUT_OF_MEM:
stRet = "Error: Out of Memory/Resources. Couldn't Execute!"
Case ERROR_FILE_NOT_FOUND:
stRet = "Error: File not found. Couldn't Execute!"
Case ERROR_PATH_NOT_FOUND:
stRet = "Error: Path not found. Couldn't Execute!"
Case ERROR_BAD_FORMAT:
stRet = "Error: Bad File Format. Couldn't Execute!"
Case Else:
End Select
End If
apiHandleFile = lRet & _
IIf(stRet = "", vbNullString, ", " & stRet)
End Function
'************ Code End **********
'another code module
Option Compare Database
Option Explicit
' ******** Code Start ********
'This code was originally written by Dev Ashish.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code Courtesy of
'Dev Ashish
'
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Declare Function apiGetVersionEx Lib "kernel32" _
Alias "GetVersionExA" _
(lpVersionInformation As Any) _
As Long
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VER_PLATFORM_WIN32_NT = 2
Function fOSName() As String
Dim osvi As OSVERSIONINFO
Dim strOut As String
osvi.dwOSVersionInfoSize = Len(osvi)
If CBool(apiGetVersionEx(osvi)) Then
With osvi
' XP
If .dwPlatformId = VER_PLATFORM_WIN32_NT And _
.dwMajorVersion = 5 And _
.dwMinorVersion = 1 Then
strOut = "Windows XP (Version " & _
.dwMajorVersion & "." & .dwMinorVersion & _
") Build " & .dwBuildNumber
If (Len(.szCSDVersion)) Then
strOut = strOut & " (" & _
fTrimNull(.szCSDVersion) & ")"
End If
End If
' .Net Server
If .dwPlatformId = VER_PLATFORM_WIN32_NT And _
.dwMajorVersion = 5 And _
.dwMinorVersion = 2 Then
strOut = "Windows .NET Server (Version " & _
.dwMajorVersion & "." & .dwMinorVersion & _
") Build " & .dwBuildNumber
If (Len(.szCSDVersion)) Then
strOut = strOut & " (" & _
fTrimNull(.szCSDVersion) & ")"
End If
End If
' Win 2000
If .dwPlatformId = VER_PLATFORM_WIN32_NT And _
.dwMajorVersion = 5 Then
strOut = "Windows 2000 (Version " & _
.dwMajorVersion & "." & .dwMinorVersion & _
") Build " & .dwBuildNumber
If (Len(.szCSDVersion)) Then
strOut = strOut & " (" & _
fTrimNull(.szCSDVersion) & ")"
End If
End If
' Win ME
If (.dwMajorVersion = 4 And _
(.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS And _
.dwMinorVersion = 90)) Then
strOut = "Windows Millenium"
End If
' Win 98
If (.dwMajorVersion = 4 And _
(.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS And _
.dwMinorVersion = 10)) Then
strOut = "Windows 98"
End If
' Win 95
If (.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS And _
.dwMinorVersion = 0) Then
strOut = "Windows 95"
End If
' Win NT
If (.dwPlatformId = VER_PLATFORM_WIN32_NT And _
.dwMajorVersion <= 4) Then
strOut = "Windows NT " & _
.dwMajorVersion & "." & .dwMinorVersion & _
" Build " & .dwBuildNumber
If (Len(.szCSDVersion)) Then
strOut = strOut & " (" & _
fTrimNull(.szCSDVersion) & ")"
End If
End If
End With
End If
fOSName = strOut
End Function
Private Function fTrimNull(strIn As String) As String
Dim intPos As Integer
intPos = InStr(1, strIn, vbNullChar)
If intPos Then
fTrimNull = Mid$(strIn, 1, intPos - 1)
Else
fTrimNull = strIn
End If
End Function
' ********** Code End **********