0

We are using UFT for automation and we have kept test data sheet [Excel file] at common location which can be access by anyone. Consider a scenario like 2 users[From 2 different machine] are executing scripts through UFT and want to update the test data sheet which is at common location.

If User 1 is updating the test data file then user 2 cannot update it at same time because it already opened by User 1. So User 2 get a message like 'File is locked for editing' This issue occurs when two user try to access the same file at same time.

Is there any solution from UFT so that both user can update the XL file?. OR is there any setting option in excel to avoid above problem.?

NOTE: Excel file is shared so can be access by anyone.

onkar
  • 249
  • 1
  • 4
  • 14
  • To get round this issue, the way I've designed it in the past is to make the non-shared, then open the file and get file status. If file status is **Read Only** then close and wait for a while and try again. This way as soon as `User 1` releases the file, `User 2` can then open it and use it. Another alternative is to consider getting data from database. I know UFT doesn't have any direct support for database but you can easily build one using VBScript (UFT default language) – Zac Aug 28 '20 at 08:55
  • Thanks Zac... Even I thought of 'Read Only' solution which you gave. But how to find runtime whether file is in read only mode or not. one solution which i thought of checking error description through using on error resume next. If error occurs it means file is in read only mode. Am I correct? – onkar Aug 28 '20 at 10:42
  • You can do it that way or you could just do something like this: `Set oWB = oXlApp.Workbook.Open(sFilename)` (here `oXlApp` is excel application object and `sFilename` holds the file path and name). Now you can check if excel file was open as read only or not by doing this: `If oWB.ReadOnly Then`. If it is, close it and wait otherwise carry on – Zac Aug 28 '20 at 10:52

1 Answers1

0

Maybe this could help.

This is what we use for local excel files, and google drive + sheets for remote editing.

But the solution is directly on excel not on uft.

https://www.ablebits.com/office-addins-blog/2017/08/02/excel-shared-workbook-share-file-multiple-users/

Juiice
  • 1
  • Thanks Juiice for your input. I tried few input as given but it didnt work. Still I am trying some other input from this links. I will let you know – onkar Aug 28 '20 at 10:11