Determine if the workbook i open is already open by another user
I have a macro that i would like to run when a Workbook is opened, but i do not want it to run if it is open by another user as the changes made will not be saved as the same file name.
I found the below code and have adapted it to fit.
It originally had and extra line under "CRSLogWB = ...." which was "Set MyWorkBook = Workbooks.Open(CRSLogWB)" But i took this out as i didn't need to open the file as it was already open.
This is what i have at the moment.
Private Sub Workbook_Open()
Dim CRSLogWB As Workbook
CRSLogWB = "\\UKBOMS01\OriginationsData\CRS\CRS LOG\CRS ORDER PROGRESS Log.xls"
If CRSLogWB.ReadOnly Then
MsgBox "Macro cannot update CRS Log this time, someone is currently using file."
Else: Call update2013
It is giving me an error - "Run-time error '91': Object variable or With block variable not set" on Line - "If CRSLogWB.ReadOnly Then".
Could anyone tell me where i have gone wrong.
Kinds regards in advance
Anwsers to the Problem Determine if the workbook i open is already open by another user
Unfortunately, this does not work in this instance as this is to be posted in the "Private Sub Workbook_Open()" of the CRSLogWB so that when i physically open the workbook, it will only run the macro if no-one else has it open.
Then I probably just misunderstood.
If you want to check in the file itself if it has the readonly state, use the code below.
Private Sub Workbook_Open()
If ThisWorkbook.ReadOnly Then
MsgBox "Macro cannot update " & ThisWorkbook.Name & " this time."
To check for Windows updates
- Open Windows Update by clicking the Start button Picture of the Start button, clicking All Programs, and then clicking Windows Update.
- In the left pane, click Check for updates, and then wait while Windows looks for the latest updates for your computer.
- If any updates are found, click Install updates. Administrator permission required If you are prompted for an administrator password or confirmation, type the password or provide confirmation.
Recommended Method to Repair the Problem: Determine if the workbook i open is already open by another user:
How to Fix Determine if the workbook i open is already open by another user with SmartPCFixer?
1. Click the button to download SmartPCFixer . Install it on your computer. Open it, and it will perform a scan for your system. The errors will be shown in the list.
2. After the scan is done, you can see the errors and problems which need to be repaired.
3. When the Fixing part is done, your computer has been speeded up and the errors have been removed
Related: How to Update & Download NVidia GeForce 6100/nForce 420 WHQL Certified driver v.178.13,How to Update & Download NVidia GeForce 7600 GS Video Driver v.295.75 Certified,How Can I Update & Download NVidia GeForce 820M Driver v.344.48 WHQL,[Solved] Download NVidia GeForce GTX 560M VGA Driver v.296.17 Certified,Way to Update & Herunterladen NVidia GeForce GT 130M Video Treiber v.295.75 Certified,How to Update & Download SONY SVE14A1X1RH Realtek Ethernet Driver,Where to Download SONY SVS13A2W9ES Bluetooth Driver (Intel) v.2.6 - 188.8.131.52059,Best Way to Update & Download SONY VGN-CR203E Conexant HDAUDIO SoftV92 Data Fax Modem with SmartCP Setup Program v.184.108.40.206 driver,Best Way to Download SONY VGN-FE790G/N Wireless LAN Driver v.10.6.0.29,Method to Update & Download SONY VGN-NR31Z/S Firmware Extension Parser Device v.220.127.116.11,How to Fix Error 0x0000c1f5 Solución?,Error 0x80071a91 Win7 Fix Patch,Error 0x800ccc60 Windows Live Mail [Solved],Error Message 0x800ccc79 Outlook 2000 Fix,What is Error 0xc1ab0001?,[Answered] x64 saplugin dll,How to Fix Problem - Kb943729 Download?,Troubleshooting: Bccode D1 Error,Java Runtime Tech Support,Troubleshooting: ERROR NO SUCH GROUP Error
Read More: Date format\/ extraction [Anwsered],Tech Support: Deleting Entire Pages With Content In MS Office Word 2010,Troubleshooter of Error: Dell popup will not go away?,Data copy, paste, sort and more.... Tech Support,Solution to Error: deleted wrong process in task manager