title: Open Excel from Word using FileDialog
body: <p>What I want to do is:</p>
  
  <ul>
  <li>Press a button in my Microsoft Word doc it will prompt me to select a document in the file explorer. </li>
  <li>Select my document the relevant fields in my word doc will be populated. </li>
  <li>This will be populated based upon information in the document (the month) and using a <code>Match</code> function it will search for the correct row/column in the selected excel document and return the value.</li>
  </ul>
  
  <p>I am stuck on the <code>FileDialog(msoFileDialogFilePicker)</code> section of my code below.</p>
  
  <p>For the purpose of my document I can not enter the direct file path, the file path needs to be taken from the <code>FileDialog</code> function (or something similar).</p>
  
  <p>I have also tried <code>GetOpenFilename</code>. I am unsure how to do this. My code currently opens FileDialog and lets me select a file, but I can not pass the file path onto my colNum1 line. </p>
  
  <p>The error I get is <em>Run-time error '91'. Object variable or With Block variable not set.</em></p>
  
  <p>I am open to suggestions and any help is much appreciated.</p>
  
  <pre><code>Sub KPI_Button()
  '
  ' KPI_Button Macro
  Dim objExcel As New Excel.Application
  Dim exWb As Excel.Workbook
  Dim strFile As String
  Dim Doc As String
  Dim Res As Integer
  Dim dlgSaveAs As FileDialog
  
  Doc = ThisDocument.Name
  
  Set dlgSaveAs = Application.FileDialog(msoFileDialogFilePicker)
  Res = dlgSaveAs.Show
  
  colNum1 = WorksheetFunction.Match("(Month)", ActiveWorkbook.Sheets("Sheet1").Range("A2:I2"), 0)
  
  ThisDocument.hoursworkedMonth.Caption = exWb.Sheets("Sheet1").Cells(3, colNum1)
  
  exWb.Close
  Set exWb = Nothing
  End Sub
  </code></pre>