The below code actually looks in...
Folder: "Q:\CS Management Reports\Reports
Setup\Administrator Files"
File: "Administrator Setup.xls"
Sheet: "Reports Setup"
cell: F6
and if the value is 1 the true part of the code runs.
This part of the code contains the msgbox. If there is a
different type of msgbox needed please let me know.
Public Sub Workbook_Open()
Dim FileFrom As String
Dim FileTo As String
Dim FName As String
Dim Res As Long
Dim UName As String * 255
Dim NN
Dim L As Long: L = 255
Dim WB As Workbook
'Adds new workbook so code below can work
Workbooks.Add
Set WB = ActiveWorkbook
'Runs the WindowsUserName function to set reference to
Library
WindowsUserName.WindowsUserName
'Runs the WindowsUserName code and trims the blanks
'Sets the variable NN to the current 5 and 2
Res = GetUserName(UName, L)
UName = Left$(UName, L - 1)
NN = Trim(UName)
p = "Q:\CS Management Reports\Reports
Setup\Administrator Files"
f = "Administrator Setup.xls"
s = "Reports Setup"
a = "F6"
'MsgBox GetValue(p, f, s, a)
If GetValue(p, f, s, a) = 1 Then
If MsgBox("An upgrade is available for Ops Reports.
Would you like to upgrade now?", vbYesNo) = vbNo Then
'Code below if answer is NO
With CreateObject("Wscript.Shell")
.Popup ("Program Update Aborted! Now quitting
Updater...") _
, 1, "Ops Reports Updater", 64
End With
WB.Close
Exit Sub
Else
'Code below if answer is YES
Workbooks("ImportData.xls").Close savechanges = False
'Copys ImportData.xls from Setup directory to users
XLSTART directory
FileFrom = "Q:\CS Management Reports\Reports
Setup\Administrator Files\Install Files\ImportData.xls"
FileTo = Application.StartupPath & "\ImportData.xls"
FileCopy FileFrom, FileTo
DoEvents
With CreateObject("Wscript.Shell")
.Popup ("Ops Reports Program Update Successfull!
Now quitting Updater...") _
, 1, "Ops Reports Updater", 64
End With
'Opens ImportData.xls after overwrite
Workbooks.Open (Application.StartupPath
& "\ImportData.xls")
WB.Close
Exit Sub
End If
End If
'Closes created workbook from start of code if no update
is available
WB.Close
End Sub