title: VBA Open workbook error?
body: <p>I am using vba to try and open a workbook (if it's not already open).</p>
  
  <p>The problem I have is sometimes the workbook can be opened by another user, so if the workbook is locked then i want to present the user an option to open the workbook in read only.</p>
  
  <p>Code:</p>
  
  <pre><code>'Open Planner
  On Error Resume Next
  Set WB = Workbooks("2017 Planner.xlsx")
  On Error GoTo 0
  If WB Is Nothing Then 'open workbook if not open
  On Error GoTo Message4
  Set WB = Workbooks.Open("G:\BUYING\Food Specials\2. Planning\1. Planning\1. Planner\8. 2017\2017 Planner.xlsx", Password:="samples", WriteResPassword:="samples", UpdateLinks:=False)
  Message4:
  Dim answer2 As Integer
  answer2 = MsgBox("Oooops!" &amp; vbNewLine &amp; vbNewLine &amp; "We had trouble opening the planner with Read/Write access. We can open the file in Read-Only but this means the planner won't automatically be updated. Would you like to continue?", vbYesNo + vbQuestion, "Notice")
  If answer2 = vbNo Then
  Exit Sub
  Else
  Set WB = Workbooks.Open("G:\BUYING\Food Specials\2. Planning\1. Planning\1. Planner\8. 2017\2017 Planner.xlsx", ReadOnly:=True, IgnoreReadOnlyRecommended:=True)
  End If
  End If
  </code></pre>
  
  <p>For some reason i get an error 1004 on this line:</p>
  
  <pre><code>Set WB = Workbooks.Open("G:\BUYING\Food Specials\2. Planning\1. Planning\1. Planner\8. 2017\2017 Planner.xlsx", ReadOnly:=True, IgnoreReadOnlyRecommended:=True)
  </code></pre>