w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Opening .xlsx with VBA, File in Use error. Read-only not working

Try using GetObject if you only need to read the file. Something like this:

Dim wb As Workbook

Set wb = GetObject(strFilename)

'Change this line to reflect the ranges you need to copy/paste.


Using this should allow you to copy from the workbook whether it's open by another user or not (including you).

I have noticed that this approach doesn't work if the workbook is protected or if the sheet you're trying to copy from is protected.

Also, only use ThisWorkbook like I did above if the code will be in the same workbook as the sheet you want to paste to.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.