What is runtime error 424

ghrek

Active Member
Joined
Jul 29, 2005
Messages
426
Hi

I have the following macro assigned to a button and when I open it in read/write it comes up with runtime error 424 Object required.

Any ideas? I need is so when someone else tries top open when already open comes up with a message box "READ ONLY"

Sub OPENOS()

Workbooks.Open Filename:= _
"\\LO-NAS01\Passenger Accounts\SHARED\passacc\Excel\passacc\os2020.xlsm" _
, UpdateLinks:=0

If Wb.ReadOnly Then
MsgBox "THIS FILE IS READ ONLY"

End If
End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
You need to define Wb before you use it. Assuming Wb is the workbook you are opening try:

Sub OPENOS()
Dim Wb as Workbook
set Wb = Workbooks.Open Filename:= _
"\\LO-NAS01\Passenger Accounts\SHARED\passacc\Excel\passacc\os2020.xlsm" _
, UpdateLinks:=0

If Wb.ReadOnly Then
MsgBox "THIS FILE IS READ ONLY"

End If
End Sub
 
Upvote 0
Sub OPENOS()
Dim Wb as Workbook
set Wb = Workbooks.Open Filename:= _
"\\LO-NAS01\Passenger Accounts\SHARED\passacc\Excel\passacc\os2020.xlsm" _
, UpdateLinks:=0

If Wb.ReadOnly Then
MsgBox "THIS FILE IS READ ONLY"

End If
End Sub
Thanks but im getting Compile error Syntax error. It defentally a workbook im trying to open
 
Upvote 0
One other thing is im trying to open a macro enabled workbook does that make any difference?
 
Upvote 0
Thanks but im getting Compile error Syntax error. It defentally a workbook im trying to open
Most likely there's some error in the path. Can't help you with that.
 
Upvote 0
You need to put the filename in brackets
VBA Code:
Set Wb = Workbooks.Open(FileName:= _
"\\LO-NAS01\Passenger Accounts\SHARED\passacc\Excel\passacc\os2020.xlsm" _
, UpdateLinks:=0)
 
Upvote 0
Solution
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,561
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top