جرب التعديلات الاتية
في ThisWorkbook ضع الكود التالي
Private Sub Workbook_Open()
Application.Visible = False
UserForm1.Show vbModeless
End Sub
حتى يظل الفورم ظاهراً فوق أي ملف إكسل آخر تفتحه، أضف الجزئية في اعلي اكواد الفورم
#If VBA7 Then
Private Declare PtrSafe Function SetWindowPos Lib "user32" (ByVal hwnd As LongPtr, ByVal hWndInsertAfter As LongPtr, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
#Else
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
#End If
Const HWND_TOPMOST = -1
Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1
قم باضافة هذا الكود للفورم
Private Sub UserForm_Initialize()
Dim hwnd As LongPtr
hwnd = FindWindow("ThunderDFrame", Me.Caption)
If hwnd <> 0 Then
SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End If
End Sub
واخيرا في ThisWorkbook ضع الكود التالي
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Application.Visible = True
ThisWorkbook.Save
ThisWorkbook.Close
End Sub
وكنت سارفق لك رابط لاخينا واستاذنا Foksh به حل للمشكلة ولكن وجدت انك صاحب الطلب نفسه فعدلت عن ذلك
وهذا كل ما لدي لجل المشكلة وبالاستعانة ببرامج الذكاء الاصطناعي