title: How to Dim and Set a variable workbook name in VBA?
body: <p>I have a workbook that gets created every week that has a variable name structure.  The name structure is as follows : <code>Week of Year</code> &amp; <code>Invoice</code> &amp; <code>date</code>.  So a sample file might be called <code>1_Invoice_01052018.xlsm</code></p>
  
  <p>I have to update the report every week.  I want to declare the variable workbook name as a variable in VBA. I have another workbook that contains the output of the report that is created via VBA.  In this other workbook I want to be able to call the <code>Invoice</code> spreadsheet but since it has a variable name, I am having issues finding it.  So I put together the VBA below. </p>
  
  <pre><code>Sub Test()
  
  Dim wb As Workbook
  Dim ws As Worksheet
  
  Set wb = "*Invoice*" &amp; ".xlsm"
  Set ws = Sheets("Sheet1")
  
  wb.Activate
  ws.Select
  
  End Sub
  </code></pre>
  
  <p>However, this results in a "Type mismatch" error.  </p>
  
  <p>I also tried the following:</p>
  
  <pre><code>Sub Test2()
  
  Windows("*Invoice*" &amp; ".xlsm").Activate
  
  End Sub
  </code></pre>
  
  <p>This also resulted in an error.</p>
  
  <p>Any ideas on how to set a variable workbook name as a variable in VBA? I would only have one of these workbooks open at a time, so I wouldn't run into any issues</p>