Determine who is opening an Excel file on Sharepoint -
i understand "environ" can identify opens file, not know how write code it.
i found 1 answer emails via outlook when file opened, ideally logged person's name , time stamped in hidden tab in worksheet or other file. since user not making edits file and/or saving don't know if option.
here's code can use. open vbe (alt+f11) double click on "thisworkbook" on in project window spreadsheet , paste in.
public declare function getusername lib "advapi32.dll" _ alias "getusernamea" (byval lpbuffer string, nsize long) long private sub workbook_open() 'when worksheet opens, write computer username ' , date , time worksheet of choice ' change "yourhiddensheetnamehere" name of ' hidden tab dim lastrow integer dim hiddensheet worksheet set hiddensheet = sheets("yourhiddensheetnamehere") lastrow = hiddensheet.range("a999999").end(xlup).row hiddensheet.cells(lastrow, 1).value = returnusername hiddensheet.cells(lastrow, 1).value = now() end function function returnusername() string ' returns nt domain user name dim rstring string * 255, slen long, tstring string tstring = "" on error resume next slen = getusername(rstring, 255) slen = instr(1, rstring, chr(0)) if slen > 0 tstring = left(rstring, slen - 1) else tstring = rstring end if on error goto 0 returnusername = ucase(trim(tstring)) end function
this fire every time opens workbook saving username used log computer date , time. saving whichever tab stick in there. you'll need save workbook .xlsm
instead of .xlsx
since macro-enabled book.
Comments
Post a Comment