maniootek

Excel - Freeze the top row

2 posts in this topic

#1 ·  Posted

In Excel there is option to freeze topmost row (A) and while you scrolling down you can always see this first row. I am looking for method to do same in Autoit. I just found 

Window.FreezePanes method which might work but I am not sure how to use it.

Share this post


Link to post
Share on other sites



#2 ·  Posted

Couple of ways:

#include <Excel.au3>

;~ Example 1
Local $oExcel = _Excel_Open()
$oExcel.ActiveWindow.FreezePanes = False
Local $sWorkbook = @ScriptDir & "\FileName.xlsx"
Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook)
$oWorkbook.ActiveSheet.Range("B2").Select
$oExcel.ActiveWindow.FreezePanes = True

;~ Example 2
Local $oExcel = _Excel_Open()
$oExcel.ActiveWindow.FreezePanes = False
Local $sWorkbook = @ScriptDir & "\FileName.xlsx"
Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook)
_Excel_FreezePanes($oExcel, 2, 2)

Func _Excel_FreezePanes($oExcel, $iCol = 0, $iRow = 1)
    If Not IsObj($oExcel) Or ObjName($oExcel, 1) <> "_Application" Then Return
    $oExcel.ActiveWindow.SplitColumn = $iCol
    $oExcel.ActiveWindow.SplitRow = $iRow
    $oExcel.ActiveWindow.FreezePanes = True
EndFunc

 

1 person likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now