title: How do I check if the Selecteditems from Filedialog is already open by user?
body: <p>I need to build in a check to see if a workbook that is selected by the user through msofiledialogopen is already open on the users computer. How do you reference this workbook instead of using a fixed name like Workbooks(&quot;Example.xlsx&quot;)?</p>
  <p>edit: The file is located on Sharepoint which may explain why I can't extract the name from the file path so easily.</p>
  <p>The code I have so far is shown below:</p>
  <pre><code>Dim ItemSelected As String, ItemSelectedName As String
  Dim wkb as Workbook
  
  With Application.FileDialog(msoFileDialogOpen) 
      .AllowMultiSelect = False
      .Title = &quot;Select Workbook&quot;
      .ButtonName = &quot;&quot;
      
      ItemSelected = .SelectedItems(1)
      ItemSelectedName = Right$(ItemSelected, Len(ItemSelected) - InStrRev(ItemSelected, &quot;\&quot;))
  
  End With
  
  If Workbooks(ItemSelectedName) Is Nothing Then
  
  Set wkb = Workbooks.Open(ItemSelected)
  
  Else
      MSGBox &quot;File already open&quot;
      Exit Sub
  End If
  
  </code></pre>