Hi
I was successful with freezing the panes with my code. my code is in a module which is called a few times by a sub. the first time the module creates a new spreadsheet and then every other time it opens the existing spreadsheet. on these subsequent iterations, the spreadsheets opens and everything works other than the freeze panes. i will copy/paste a snippet of the code.
thanks
sam
I was successful with freezing the panes with my code. my code is in a module which is called a few times by a sub. the first time the module creates a new spreadsheet and then every other time it opens the existing spreadsheet. on these subsequent iterations, the spreadsheets opens and everything works other than the freeze panes. i will copy/paste a snippet of the code.
thanks
sam
Code:
Set MyExcelInstance = New Excel.Application
If intCount = 1 Then
Set MyWorkbook = MyExcelInstance.Workbooks.Add
Excel.Application.DisplayAlerts = False
MyWorkbook.SaveAs "C:\" & ReportName
Excel.Application.DisplayAlerts = True
Else
Set MyWorkbook = MyExcelInstance.Workbooks.Open("C:\" & ReportName & ".xls")
End If
Set MySheet = MyWorkbook.Worksheets.Add
MySheet.Name = strPaygroup
MySheet.Paste Destination:=MySheet.Range("A1")
MyWorkbook.Save
MsgBox MyExcelInstance
'freeze panes
MySheet.Range("A5").Select
ActiveWindow.FreezePanes = True