I'm searching for a way to freeze the upper part of my Excel sheet (with headers and such, like the 'freeze panes' menu option in Excel), from my Access VBA code. I've been searching for a while but didn't come up with something usefull. Anyone any suggestions

Thanks in advance, I'd be really glad if someone knows this!

Re: Excel 'Freeze panes' from Access VBA (Off2000)


Got it working, if anyone wants to know:
Code Snippet

  1. Dim oApp As New Excel.Application
  2. Dim oBook As Excel.Workbook
  3. Dim oSheet As Excel.Worksheet
  4. Set oBook = oApp.Workbooks.Add 'Open a new workbook
  5. Set oSheet = oBook.Worksheets(1) 'with a new sheet
  6. oSheet.PageSetup.Orientation = xlLandscape 'In Landscape for printing purposes
  7. oSheet.PageSetup.Zoom = fnZoomLevel(Name) ' Zoom level for printing
  8. oSheet.Name = fnName(Name) ' Give the sheet the right name (name of grade)
  9. oSheet.Range("A4").Select
  10. oApp.ActiveWindow.FreezePanes = True

Works like a dream.

Btw, is this forum dead Or anyone still posting here...