ActiveWindow.FreezePanes = True
Yes, tried that, didn't work at first. Got it working now however:
-
-
Dim oApp As New Excel.Application
-
Dim oBook As Excel.Workbook
-
Dim oSheet As Excel.Worksheet
-
-
Set oBook = oApp.Workbooks.Add 'Open a new workbook
-
Set oSheet = oBook.Worksheets(1) 'with a new sheet
-
oSheet.PageSetup.Orientation = xlLandscape 'In Landscape for printing purposes
-
oSheet.PageSetup.Zoom = fnZoomLevel(Name) ' Zoom level for printing
-
oSheet.Name = fnName(Name) ' Give the sheet the right name (name of grade)
-
-
oSheet.Range("A4").Select
-
oApp.ActiveWindow.FreezePanes = True
-
I tried 'ActiveWindow' as a property of oSheet, that didn't work of course ;) You also need to select the right cell before setting the FreezePanes property.
Works like a dream now. Thanks!
Jasper