I have the following code that is intended to save and close a particular workbook after 30 mins of inactivity. I get an error however when it is run and I think its because I have other excel workbooks open. I think i need to reference the workbook I am interested in but dont know how to do so. The workbook I want to refer to is P:\Departments Online\Property\Activity\Activity.xlsm
Sub Inactivity()
Dim x As Integer
Dim MyTxtFile
x = Application.Match(Environ("username"), ActiveWorkbook.Sheets("Users").Columns("A"), 0) <<<<<<Error is on this line of code
FullName = ActiveWorkbook.Sheets("Users").Cells(x, 2)
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("P:\Departments Online\Property\Activity\Inactivity.txt", True)
a.WriteLine (FullName & " you have been kicked out of Activity due to over 30 mins of Inactivity. Please close this message.")
MyTxtFile = Shell("C:\WINDOWS\notepad.exe P:\Departments Online\Property\Activity\Inactivity.txt", 1)
End Sub
Bookmarks