U
| Problem | Makro |
| Userform Startparameter mitgeben. | 'Legt beim Start der
Userform die Hintergrundfarbe fest
Private Sub UserForm_Initialize() |
| Userform als Startbildschirm | von Werner Rohrmoser
'Beim Schließen der Datei Workbook
ausblenden |
| Userform im "Vollbildmodus" | Public Sub UserForm_Initialize() 'Excel maximieren Application.WindowState = xlMaximized 'Userform auf Excelgröße maximieren With Me .Height = Application.Height .Width = Application.Width End With End Sub |
| Uhrzeit fortlaufend in Zelle aktuell anzeigen | Sub Uhrzeit() [A1] = Format(Time, "hh:mm:ss") Application.OnTime Now + TimeValue("00:00:01"), "Uhrzeit" End Sub |
| Das Schließen-X einer Userform deaktivieren | 'Dieses Makro stammt
nicht von mir, Ersteller unbekannt. 'Bitte alle Makros verwenden! Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, _ ByVal bRevert As Long) As Long Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, _ ByVal nPosition As Long, ByVal wFlags As Long) As Long Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long Private Const MF_BYPOSITION = &H400& Private Sub UserForm_Activate() Dim hwnd As Long hwnd = GetActiveWindow() TakeCloseOff hwnd hwnd = DrawMenuBar(hwnd) End Sub Public Sub TakeCloseOff(Handle As Long) Dim SysMenHandle As Long, RetVal As Long SysMenHandle = GetSystemMenu(Handle, 0) 'Get the handle of Form1's Window menu RetVal = RemoveMenu(SysMenHandle, 6, MF_BYPOSITION) 'Take out Close item End Sub ' Man muss sicherstellen, das die Userform geschlossen werden kann. ' In diesem Fall durch Doppelklick auf die Userform. Private Sub UserForm_DblClick(ByVal Cancel As MSForms.ReturnBoolean) Unload Me End Sub Private Sub UserForm_Initialize() 'Zur Demo: Me.BackColor = RGB(250, 250, 220) End Sub |