![]() |
Disable Min Max restore buttons
How do I Hide / disable Min/Max/Close buttons in XLapp and XlWorkbook windows
If cant be done then how can i direct code towards a button on a form which sits over the spreadsheet and perform the button click event of that for I am automating excel for VB.net Cheer pete |
Disable Min Max restore buttons
Hi Pete,
Perhaps like that: Set xlApp = WScript.CreateObject("Excel.Application") Set xlWbk = xlApp.Workbooks.Add xlApp.ActiveWorkbook.VBProject.VBComponents.Add(1) .Name = "TmpModul" AddCodeLine "TmpModul", "Private Declare Function FindWindowA Lib ""User32"" (ByVal lpClassName$, ByVal lpWindowName$) As Long" AddCodeLine "TmpModul", "Private Declare Function SetWindowLongA Lib ""User32"" (ByVal hWnd&, ByVal nIndex&, ByVal dwNewLong&) As Long" AddCodeLine "TmpModul", "Private Declare Function DrawMenuBar Lib ""User32"" (ByVal hWnd&) As Long" AddCodeLine "TmpModul", "" AddCodeLine "TmpModul", "Sub LockExcel()" AddCodeLine "TmpModul", "ActiveWindow.WindowState = xlMaximized" AddCodeLine "TmpModul", "ThisWorkbook.Unprotect" AddCodeLine "TmpModul", "ActiveWindow.WindowState = xlMaximized" AddCodeLine "TmpModul", "Dim hWnd As Long" AddCodeLine "TmpModul", "hWnd = FindWindowA(vbNullString, Application.Caption)" AddCodeLine "TmpModul", "SetWindowLongA hWnd, -16, &H15470000" AddCodeLine "TmpModul", "DrawMenuBar hWnd" AddCodeLine "TmpModul", "ThisWorkbook.Protect Structu=False, Windows:=True" AddCodeLine "TmpModul", "End sub" xlApp.Visible = True xlApp.Run xlWbk.Name & "!LockExcel" With xlApp.ActiveWorkbook.VBProject.VBComponents .Remove .Item("TmpModul") End With ' ... Set xlWbk = Nothing Set xlApp = Nothing Sub AddCodeLine(strComponentName, strCodeLine) With xlApp.ActiveWorkbook.VBProject.VBComponents(strCom ponentName).CodeModule .InsertLines .CountOfLines + 1, strCodeLine End With End Sub MP "PeteSmith" a écrit dans le message de ... How do I Hide / disable Min/Max/Close buttons in XLapp and XlWorkbook windows. If cant be done then how can i direct code towards a button on a form which sits over the spreadsheet and perform the button click event of that form I am automating excel for VB.net Cheers pete |
All times are GMT +1. The time now is 07:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com