ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Hide Close Button Excel 2007 (https://www.excelbanter.com/excel-discussion-misc-queries/144649-hide-close-button-excel-2007-a.html)

[email protected]

Hide Close Button Excel 2007
 
Hi,

I want to hide Minimize/Maximize/Close("X") buttons of an Excel
sheet(2007) which appears on title bar. To hide the buttons
programmatically, i write following code:

Please assume that my excel sheet is opened on desktop whose caption
is: "EXCELSHEET_TEST"

------------------------------------------------------------------------------------------------------------
HWND hwndExcelHandler = FindWindow(NULL, "EXCELSHEET_TEST");
DWORD dwStyle = GetWindowLong(hwndExcelHandler, GWL_STYLE);
::SetWindowLong(hwndExcelHandler, GWL_STYLE, (dwStyle &
~WS_MAXIMIZEBOX));

dwStyle = GetWindowLong(hwndExcelHandler, GWL_STYLE);
::SetWindowLong(hwndExcelHandler, GWL_STYLE, (dwStyle &
~WS_MINIMIZEBOX));

HMENU hMenuOfXLS = ::GetSystemMenu(hwndExcelHandler, false);
::DeleteMenu(hMenuOfXLS, SC_CLOSE, MF_BYCOMMAND); //ok actually
remove the close button
------------------------------------------------------------------------------------------------------------

This code successfully hides MINIMIZE and MAXIMIZE buttons, but it
doesn't hide CLOSE("X") button appears on title bar.

I tried testing it with Excel 2003 and it gives me expected results.
It hides all of three buttons MINIMIZE/MAXIMIZE/CLOSE of Excel 2003
titlebar.

Can anyone please suggest me why this code doesn't works for Excel
2007?

Any suggestion on the same would be appreciated.

Thank You,
Jaydeep



All times are GMT +1. The time now is 02:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com