WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Excel
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Display Users on Excel Workbook


;Winbatch - Display Users on Excel Workbook
; Determines if a workbook is shared or exclusive and parses out the user info
;
;
;Stan Littlefield June 28, 2006
;//////////////////////////////////////////////////////////////////////////////////

;the UserStatus property appears to register the user name from the Tools/Properties/General/User Name rather than
;from the logged in user. Also, if the file is not in use, the function will still register the GetObject() instance as a user.
#DefineSubRoutine GetXL()
   oWkb=GetObject(cXLS)
   aUsers = oWkb.UserStatus
   If VarType(aUsers)<>512
      Display(2,"WorkBook Not in Use",cXLS)
   Else
      cOut = StrCat(DirScript(),"users.csv")
      ArrayFilePutCSV(cOut,oWkb.Parent.WorksheetFunction.TransPose(aUsers), ",",1,2)
      ;array file will have 3 csv field per row
      ;1=user name 2=when logged in 3=type of use [Exclusive=1,Shared=2]
      Message(StrCat("Users:",cXLS),FileGet(cOut))
   EndIf
   oWkb=0
   Return(1)
#EndSubRoutine

cXLS = AskFilename("Check WorkBook For Users", DirScript(), "Excel Files|*.xls|", "", 1)
If cXLS=="" Then Exit

;Get the current user list
GetXL()
Exit

;//////////////////////////////////////////////////////////////////////////////////

Article ID:   W17151
File Created: 2007:07:03:14:28:30
Last Updated: 2007:07:03:14:28:30