title: Generate Excel Spreadsheet with a Freezepane
body: <p>I've trying to create a spreadsheet with a freeze pane for the first 5 row. I've got it creating an excel spreadsheet but for some reason my freeze pane only freezes the first 2 rows and first 2 columns.</p>
  
  <pre><code>With objExcelAssist.worksheet
      Dim xlApp As Object
      Set xlApp = objExcelAssist.Application
      xlApp.ActiveWindow.FreezePanes = True
  End With
  </code></pre>
  
  <p>I've tried doing:</p>
  
  <pre><code>Dim rv As Object
  Dim rng As Object
  
  Set rng = rv.Range(rv.Cells(4, 2), rv.Cells(4, 2))
  rng.select
  rv.Application.ActiveWindow.FreezePanes = True
  </code></pre>
  
  <p>But I get the error: 'Object variable or With block variable not set'</p>
  
  <p>Any help on how I can get my Excel document to freeze the first top 5 rows would be great.</p>
  
  <p>Thanks</p>
  
  <p>---- Edit ----</p>
  
  <pre><code>With objExcelAssist.worksheet
      Range("A6").Select
      ActiveWindow.FreezePanes = True
  
      .Rows(1).RowHeight = 21
      .columns(1).ColumnWidth = 11
      .Rows(objExcelReport.firstDataRow - 1).Autofilter
  End With
  </code></pre>
  
  <p>I got this now with 'Range'</p>
  
  <p><img src="https://i.stack.imgur.com/ndNSC.png" alt="Tries a suggestion someone posted but still got the same problem"></p>