Discussion:
freeze panes from vba
(too old to reply)
Keith G Hicks
2010-02-26 19:19:23 UTC
Permalink
This works in a macro inside Excel

Range("G2").Select
ActiveWindow.FreezePanes = True

It does exactly what I'd expect. It puts a horizontal freeze line between
row 1 and row 2 and a vertical freeze line between column F and column G.

But I need to use from MS Access vba code so I'm doing this:

objExcelSht.Range("G2").Select
objExcelApp.ActiveWindow.FreezePanes = True

It does freeze but not the same way. It only puts in a vertical freeze line
between columns F and G. There is no horizontal freeze line.

What do I hvae to do from vba in Access to get the same results?

Thanks,

Keith
Keith G Hicks
2010-02-26 19:35:29 UTC
Permalink
Well this is odd. It works fine if I dont' make the thing visible until
after the entire process is complete. So I guess I'm okay. But I think it
should work even if it's visible while being created so input would be
appreciated anyway.
Post by Keith G Hicks
This works in a macro inside Excel
Range("G2").Select
ActiveWindow.FreezePanes = True
It does exactly what I'd expect. It puts a horizontal freeze line between
row 1 and row 2 and a vertical freeze line between column F and column G.
objExcelSht.Range("G2").Select
objExcelApp.ActiveWindow.FreezePanes = True
It does freeze but not the same way. It only puts in a vertical freeze
line between columns F and G. There is no horizontal freeze line.
What do I hvae to do from vba in Access to get the same results?
Thanks,
Keith
Dave Peterson
2010-02-26 20:01:11 UTC
Permalink
I've always selected the sheet first
removed the freeze panes
selected A1 to make sure it's visible
select the cell that I really want to use
and reapply the freeze panes.

Dim wks As Worksheet
Set wks = Worksheets("Sheet1")
With wks
.Parent.Activate 'correct workbook
.Select 'correct sheet
ActiveWindow.FreezePanes = False
.Range("A1").Select
.Range("G2").Select
ActiveWindow.FreezePanes = True
End With

(this is from within excel.)
Post by Keith G Hicks
This works in a macro inside Excel
Range("G2").Select
ActiveWindow.FreezePanes = True
It does exactly what I'd expect. It puts a horizontal freeze line between
row 1 and row 2 and a vertical freeze line between column F and column G.
objExcelSht.Range("G2").Select
objExcelApp.ActiveWindow.FreezePanes = True
It does freeze but not the same way. It only puts in a vertical freeze line
between columns F and G. There is no horizontal freeze line.
What do I hvae to do from vba in Access to get the same results?
Thanks,
Keith
--
Dave Peterson
Loading...