Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Buttons for Minimize, Restore and Close missing from Workbook CharlieD Excel Discussion (Misc queries) 1 January 30th 08 06:06 PM
Disable Cut & Copy then restore on exiting sparx Excel Discussion (Misc queries) 0 April 30th 06 08:43 PM
Restore superscript and subscript buttons in Excel toolbars dandc01 Excel Discussion (Misc queries) 1 February 13th 06 06:43 PM
excel 'lost my title bar with min. restore down, close buttons' Bill Geary Excel Discussion (Misc queries) 0 July 14th 05 08:34 PM
Disabling Minimise/Restore Down buttons Scampa7[_2_] Excel Programming 1 October 25th 03 07:05 PM


All times are GMT +1. The time now is 08:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"