Wednesday, 22 March 2017
Unable to set the Freeze Panes property of Window Class C#
It is generally easy to resolve the compile time errors because the reason for the error is probably known but a run time error always hinders the development process for a considerable amount of time so are the exceptions that unknowingly show up from no where. That is why it is always advised to handle each and every exception your application might throw. The only way to be a master in handling exception is experience, yeah you read it right. More you develop, more problem you will encounter in your developing environment and in turn more you will know the reason and the so called timing of the exceptions.
Exception
One of the most encountered is "unable to set freeze panes property of window class" which show up when you try to freeze panes while formatting an excel file in c#.
Reason
The main reason for occurrence of such an exception is incompatibility between older and the newer versions of MS Excel.
When it occirs
This exception occurs when you are using a newer version of MS Excel and your application gets activate in background, I repeat your MS Excel application thread opens in the minimized state which hinders the freezing pane process.
How to counter this exception?
Obviously to get a solution to a problem, first of all understanding the problem is must more precisely the reason of problem should be known. Since we know the reason why freeze panes property is not set and the exception is thrown we can provide a solution.
So if somehow we can make our MS Excel thread open in maximized state or normal state explicitly then bingo we successfully resolved the issue.
Still it is a good practice to surround the exception causing snippet with try block and catch the exception so that there is no exceptional flow change in your application.
Let us look at the source code for the same
Exception
One of the most encountered is "unable to set freeze panes property of window class" which show up when you try to freeze panes while formatting an excel file in c#.
Reason
The main reason for occurrence of such an exception is incompatibility between older and the newer versions of MS Excel.
When it occirs
This exception occurs when you are using a newer version of MS Excel and your application gets activate in background, I repeat your MS Excel application thread opens in the minimized state which hinders the freezing pane process.
How to counter this exception?
Obviously to get a solution to a problem, first of all understanding the problem is must more precisely the reason of problem should be known. Since we know the reason why freeze panes property is not set and the exception is thrown we can provide a solution.
So if somehow we can make our MS Excel thread open in maximized state or normal state explicitly then bingo we successfully resolved the issue.
Still it is a good practice to surround the exception causing snippet with try block and catch the exception so that there is no exceptional flow change in your application.
Unable to Set Freeze Panes Exception |
Let us look at the source code for the same
Source Code
//Maximize the window state before setting freeze panes property
ExcelApp.Application.ActiveWindow.WindowState = Microsoft.Office.Interop.Excel.XlWindowState.xlMinimized;
ExcelApp.Columns.AutoFit();
try
{
ExcelApp.Application.ActiveWindow.FreezePanes = false;
ExcelApp.Application.ActiveWindow.SplitColumn = 1; //To freeze first column
ExcelApp.Application.ActiveWindow.SplitRow = 1; // To freeze Top Row
ExcelApp.Application.ActiveWindow.FreezePanes = true;
}
catch(Exception ex)
{
}
Also Read Troubleshooting Cisco VPN client 0x8004a029 with screenshots
Also Read Troubleshooting ORA-12505
Also Read Troubleshooting ORA-12505
Subscribe to:
Post Comments (Atom)
Search
Popular Posts
-
Troubleshooting Cisco VPN client Before starting troubleshooting, Let us see what VPN is and what it requires to perform its intended f...
-
Evolution-Mobile Phones With the development of portable technology,wireless communication has so evolved that (According to the announce...
-
File Versioning C# File versioning, saving file with unique file name in c# File versioning allows a user to have several versions of ...
-
Text Box Hint in c# Windows Form Application Text Box Hint in c# Windows Form Application While developing a windows form applicat...
-
Unable to set the Freeze Panes property of Window Class C# It is generally easy to resolve the compile time errors because the reason fo...
067A73F7C0
ReplyDeletetürk takipçi instagram
AC17CC5960
ReplyDeleteinstagram takipçi bot
4DB056FA0F
ReplyDeletetelegram coin botları
yatırımsız coin kazan
oyun oyna coin kazan
görev yap coin kazan
butona bas coin kazan
C7DEC0E1FF
ReplyDeleteTelegram Farm Botları
Telegram Farm
Telegram Para Kazanma
Yeni Telegram Airdrop Botları
Para Kazanma Botları
433511A1D2
ReplyDeleteListelenecek Airdroplar Telegram
Yeni Telegram Airdrop Oyunları
En Yeni Telegram Airdrop
Yeni Telegram Airdrop Botları
Telegram Güvenilir Mining Botları
A9C07F3FC8
ReplyDelete-
-
bayan kuşadası
-
-