title: Set Prompted Excel Spreadsheet to new Workbook Object
body: <p>I'm trying to assign a new excel worksheet that is being prompt to open as a new Workbook Object. I'm trying the below code, however it's not working</p>
  
  <pre><code>Option Explicit
  
  Sub MoveGeneratedReport()
  
     Dim newWbReport As Workbook
     Dim MonthlyComplianceReport As Workbook
  
     Set MonthlyComplianceReport = SelectWorkbook
  
  End Sub
  
  Private Function SelectWorkbook() As Workbook
  
     Dim strFileToOpen As String
     strFileToOpen = Application.GetOpenFilename(Title:="Select Compliancy Report for export", _
                     FileFilter:="Excel Files *.xls* (*.xls*),")
  
     If strFileToOpen &lt;&gt; False Then  '&lt;---- Error Ocuring here
        Workbooks.Open Filename:=strFileToOpen
     End If
  
  End Function
  </code></pre>
  
  <p>I'm receiving the </p>
  
  <blockquote>
    <p>"Type Mismatch"</p>
  </blockquote>
  
  <p>error, however if I just run the function <code>SelectWorkbook()</code> it works fine and opens the document.</p>
  
  <p>My end goal here is to open the document and then assign it to a Workbook object. Any suggestions to fix this error?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I should clarify my question here too... How can I assign this newly opened Workbook via the prompt to a Workbook object so that the rest of my code can work with it?</p>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>This seems to be working really well</p>
  
  <pre><code>Option Explicit
  
  Sub MoveGeneratedReport()
  
     Dim newWbReport As Workbook
     Dim MonthlyComplianceReport As Workbook
  
     Set MonthlyComplianceReport = SelectWorkbook
  
  
     Debug.Print MonthlyComplianceReport.Name
  
  End Sub
  
  Private Function SelectWorkbook() As Workbook
  
     Dim strFileToOpen As String
     strFileToOpen = Application.GetOpenFilename(Title:="Select Compliancy Report for export", _
                     FileFilter:="Excel Files *.xls* (*.xls*),")
  
     If strFileToOpen &lt;&gt; "" Then
        On Error GoTo ErrHandle
        Set SelectWorkbook = Workbooks.Open(Filename:=strFileToOpen)
     End If
  
     Exit Function
  ErrHandle:
     If Err.Number &lt;&gt; 1004 Then
        MsgBox "Error " &amp; Str(Err.Number) &amp; Chr(13) &amp; _
               "Error Line: " &amp; Erl &amp; Chr(13) &amp; Chr(13) &amp; _
               Err.Description
     End If
  
  End Function
  </code></pre>