Menghilangkan "x" Pada Userform Excel

VBA Excel Menghilangkan Tanda "x" Pada Userform Excel.

Bagaimana Caranya ?

Yuk kita bahas sama-sama..

Langkah-langkah Menghilangkan "x" di Userform Excel


  1. Buka Excel Anda
  2. Simpan dan beri nama file Menyembunyikan "x" Pada Userform
  3. Pilih extensi .xlsb yaitu Excel Binary Workbook
  4. Buka jendela VBA Excel (Tekan Alt+F11 atau lewat menu ribbon Developer > Visual Basic)
  5. Buat 1 buah Module dan salin Kode Macro dibawah ini kedalam Module tersebut
  6. Option Explicit
    Private Const MF_BYPOSITION = &H400
    Private Const MF_REMOVE = &H1000
    Private Const WS_SYSMENU = &H80000
    Private Const GWL_STYLE = (-16)
    Private hwnd As Long
    Private lStyle As Long
    
    #If VBA7 And Win64 Then
    Private Declare PtrSafe Function FindWindow Lib "user32" _
            Alias "FindWindowA" (ByVal lpClassName As String, _
            ByVal lpWindowName As String) As LongLong
    Private Declare PtrSafe Function GetWindowLong Lib "user32" _
            Alias "GetWindowLongA" (ByVal hwnd As Long, _
            ByVal nIndex As Long) As LongLong
    Private Declare PtrSafe Function SetWindowLong Lib "user32" _
            Alias "SetWindowLongA" (ByVal hwnd As Long, _
            ByVal nIndex As Long, _
            ByVal dwNewLong As Long) As LongLong
    Private Declare PtrSafe Function DrawMenuBar Lib "user32" _
            (ByVal hwnd As Long) As LongLong
    Private Declare PtrSafe Function GetMenuItemCount Lib "user32" _
                    (ByVal hMenu As Long) As LongLong
    Private Declare PtrSafe Function GetSystemMenu Lib "user32" _
                    (ByVal hwnd As Long, _
                    ByVal bRevert As Long) As LongLong
    Private Declare PtrSafe Function RemoveMenu Lib "user32" _
                    (ByVal hMenu As Long, ByVal nPosition As Long, _
                    ByVal wFlags As Long) As LongLong
    #Else
    Private Declare Function FindWindow Lib "user32" _
                    Alias "FindWindowA" _
                    (ByVal lpClassName As String, _
                    ByVal lpWindowName As String) As Long
    Private Declare Function GetWindowLong Lib "user32" _
                    Alias "GetWindowLongA" _
                    (ByVal hwnd As Long, _
                    ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" _
                    Alias "SetWindowLongA" _
                    (ByVal hwnd As Long, _
                    ByVal nIndex As Long, _
                    ByVal dwNewLong As Long) As Long
    Private Declare Function DrawMenuBar Lib "user32" _
                    (ByVal hwnd As Long) As Long
    Private Declare Function GetMenuItemCount Lib "user32" _
                    (ByVal hMenu As Long) As Long
    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
    #End If
    
    Sub HideXCloseButton(oForm As Object)
    hwnd = FindWindow("ThunderDFrame", oForm.Caption)
    lStyle = GetWindowLong(hwnd, GWL_STYLE)
    SetWindowLong hwnd, GWL_STYLE, lStyle And Not WS_SYSMENU
    End Sub
    
  7. Kemudian buatlah 1 buah userform dan salin kode macro dibawah ini dan tempelkan kedalam userform (klik 2x Userform dan pastekan)
  8. Option Explicit
    Private Sub UserForm_Initialize()
    Module1.HideXCloseButton Me
    End Sub
    
    Untuk menghindari tidak bisa end userform, kita buat 1 tombol close pada userform tersebut
  9. Buatlah 1 buah Tombol pada userform dan masukan kode macro dibawah ini kedalam tombol tersebut
  10. Option Explicit
    Private Sub UserForm_Initialize()
    Module1.HideXCloseButton Me
    End Sub
    
  11. Untuk mencobanya silahkan klik RUN atau tekan F5

Jika Anda melakukan langkah-langkah diatas dengan benar dan penempatan kode juga benar maka jadinya akan seperti gambar dibawah ini
Mengilangkan Tanda X Userform - VBA Excel

Penutup


Kami juga memikirkan pemahaman dari semua pengunjung, sehingga selain artikel, kami juga memberikan file penerapan untuk pemahaman mendalam.

Nama File Menghilangkan "x" Userform Excel
Extensi .xlsb
Size 26kb
Berkas

Terimakasih sudah berkunjung :)

Bantu kami meningkatkan kualitas blog ini dengan mengisi survei 1 menit.

©2017| dolananexcel.id

Post a Comment for "Menghilangkan "x" Pada Userform Excel"