Xin cách cố định userform (3 người xem)

  • Thread starter Thread starter kuvi1324
  • Ngày gửi Ngày gửi
Liên hệ QC

Người dùng đang xem chủ đề này

kuvi1324

Thành viên chính thức
Tham gia
1/2/13
Bài viết
78
Được thích
0
Userform mình có code

Private Sub UserForm_Initialize()
Application.WindowState = xlMaximized
Me.Top = 0: Me.Left = 0
Me.Width = Application.Width
Me.Height = Application.Height
Worksheets("Nhaphoso").Select
Range(Cells(8, 3), Cells(8, 9)).Value = ""
Range(Cells(13, 1), Cells(13, 20)).Value = ""
Range(Cells(16, 1), Cells(16, 6)).Value = ""
Range(Cells(16, 9), Cells(26, 9)).Value = "."
Range(Cells(31, 6), Cells(31, 11)).Value = ""
End Sub

Giờ cần cố định không cho di chuyển qua lại userform thì làm thế nào mọi người
 
Userform mình có code

Private Sub UserForm_Initialize()
Application.WindowState = xlMaximized
Me.Top = 0: Me.Left = 0
Me.Width = Application.Width
Me.Height = Application.Height
Worksheets("Nhaphoso").Select
Range(Cells(8, 3), Cells(8, 9)).Value = ""
Range(Cells(13, 1), Cells(13, 20)).Value = ""
Range(Cells(16, 1), Cells(16, 6)).Value = ""
Range(Cells(16, 9), Cells(26, 9)).Value = "."
Range(Cells(31, 6), Cells(31, 11)).Value = ""
End Sub

Giờ cần cố định không cho di chuyển qua lại userform thì làm thế nào mọi người

Muốn Zoom Form bằng màn hình, thì làm như sau:

Mã:
Option Explicit
Private prihWnd&
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
        (ByVal lpClassName As String, ByVal lpWindowName As String) As Long



Private Sub UserForm_Initialize()
    prihWnd = FindWindow("ThunderDFrame", Caption)
    Worksheets("Nhaphoso").Select
    Range(Cells(8, 3), Cells(8, 9)).Value = ""
    Range(Cells(13, 1), Cells(13, 20)).Value = ""
    Range(Cells(16, 1), Cells(16, 6)).Value = ""
    Range(Cells(16, 9), Cells(26, 9)).Value = "."
    Range(Cells(31, 6), Cells(31, 11)).Value = ""
End Sub


Private Sub UserForm_Activate()
    'Full screen:
    ShowWindow prihWnd, 3
End Sub

Muốn cố định Form thì xóa cái Caption của Form đi, nhưng cần phải thêm trong form 1 nút lệnh THOÁT.
 
Lần chỉnh sửa cuối:
Upvote 0
Bạn thử thay dòng

Me.Top = 0: Me.Left = 0

Bằng
Me.Top = 100: Me.Left = 100

Và đánh dấu check phía trước hoặc bỏ 2 dòng này, rồi thử xem nó thế nào.

Me.Width = Application.Width
Me.Height = Application.Height

 
Upvote 0
Bạn thử thay dòng

Me.Top = 0: Me.Left = 0

Bằng
Me.Top = 100: Me.Left = 100

Và đánh dấu check phía trước hoặc bỏ 2 dòng này, rồi thử xem nó thế nào.


Nhìn code của bạn ấy là biết muốn form zoom bằng màn hình rồi, nhưng cách mà "ăn theo" kích thước của cửa sổ Excel thì có vẻ như không hay lắm. Nên chọn phương pháp dùng hàm API.

Và đã muốn nó có left và top theo ý muốn thì nên chọn trong Properties của Form mục StarUpPosition là Manual và code chỉ cần viết:

Mã:
Private Sub UserForm_Initialize()
    Application.WindowState = xlMaximized
    Me.Width = Application.Width
    Me.Height = Application.Height
End Sub
 

File đính kèm

  • Prop.jpg
    Prop.jpg
    47.9 KB · Đọc: 26
Upvote 0
Web KT

Bài viết mới nhất

Back
Top Bottom