Option Explicit Private Const VBEXT_CT_MSFORM As Long = 3 Public Sub CreateUserForm1Design_Final() Dim vbProject As Object, vbComponent As Object, formDesigner As Object, oldComp As Object On Error GoTo EH Set vbProject = ActiveDocument.VBProject On Error Resume Next Set oldComp = vbProject.VBComponents("UserForm1") On Error GoTo EH If Not oldComp Is Nothing Then MsgBox "UserForm1이 이미 있습니다. 기존 폼을 지우고 다시 실행해주세요.", vbExclamation: Exit Sub End If Set vbComponent = vbProject.VBComponents.Add(VBEXT_CT_MSFORM) vbComponent.Name = "UserForm1" With vbComponent .Properties("Caption").Value = "규율위반자 개인별 명부 작성" .Properties("Width").Value = 900 .Properties("Height").Value = 760 .Properties("BackColor").Value = RGB(247, 250, 244) .Properties("StartUpPosition").Value = 1 End With Set formDesigner = vbComponent.Designer AddLabel formDesigner, "lblTitle", "규율위반자 개인별 명부 작성", 18, 10, 850, 30, 20, True, 2, RGB(247, 250, 244) ' 1번 섹션 AddSectionBar formDesigner, "lblPersonSection", "1. 인적사항 엑셀 선택 (Word 메일 병합 연결)", 20, 50, 840, 25 AddLabel formDesigner, "lblExcel", "엑셀 파일", 25, 90, 80, 25, 11, True AddTextBox formDesigner, "txtExcelPath", 110, 88, 590, 30, False, True AddButton formDesigner, "btnBrowse", "파일 선택", 715, 87, 140, 32, RGB(226, 239, 218) AddLabel formDesigner, "lblExcelNotice", "※ 주의: 수용자 경비처우급 조정 및 수용자 변동사항 시 오기될 수 있으니 주기적으로 데이터를 최신화해 주시기 바랍니다.", 110, 125, 745, 20, 9.5, True, 1, -1, RGB(255, 0, 0) ' 2번 섹션 AddSectionBar formDesigner, "lblInputSection", "2. 위반내용 입력 및 명단 추가 ※ Tab 키로 다음 입력칸으로 이동할 수 있습니다.", 20, 160, 840, 25 AddButton formDesigner, "btnClearSavedInputs", "모든 저장 해제", 710, 162, 140, 21, RGB(242, 242, 242) AddLabel formDesigner, "lblNumber", "번호", 25, 203, 45, 20, 11, True AddTextBox formDesigner, "txtNumber", 75, 200, 100, 32, False, False AddLabel formDesigner, "lblViolationDate", "날짜", 185, 203, 40, 20, 11, True AddTextBox formDesigner, "txtViolationDate", 230, 200, 85, 32, False, False AddLabel formDesigner, "lblViolationTime", "시각", 325, 203, 40, 20, 11, True AddTextBox formDesigner, "txtViolationTime", 370, 200, 65, 32, False, False AddCheckBox formDesigner, "chkSaveViolationDateTime", "날짜·시각 저장", 440, 204, 105, 25 AddLabel formDesigner, "lblReporterRank", "직급", 550, 203, 40, 20, 11, True AddTextBox formDesigner, "txtReporterRank", 595, 200, 55, 32, False, False AddLabel formDesigner, "lblReporterName", "성명", 655, 203, 40, 20, 11, True AddTextBox formDesigner, "txtReporterName", 700, 200, 55, 32, False, False AddCheckBox formDesigner, "chkSaveReporter", "직급·성명 저장", 760, 204, 100, 25 ' ★ 위반내용: 드롭다운(높이 32) + 텍스트칸(높이 45로 확장, 자연스런 줄바꿈 허용) AddLabel formDesigner, "lblViolationContent", "위반내용", 25, 253, 110, 20, 11, True AddComboBox formDesigner, "cmbViolationList", 140, 250, 180, 32 AddTextBox formDesigner, "txtViolationContent", 330, 250, 415, 45, True, False ' 높이 45로 넉넉하게 변경! AddCheckBox formDesigner, "chkSaveViolationContent", "저장", 755, 260, 70, 25 AddLabel formDesigner, "lblNote", "비고", 25, 313, 110, 20, 11, True AddTextBox formDesigner, "txtNote", 140, 310, 300, 32, False, False AddCheckBox formDesigner, "chkSaveNote", "저장", 450, 314, 70, 25 AddButton formDesigner, "btnAdd", "명단에 추가", 535, 305, 100, 40, RGB(198, 224, 180), True AddButton formDesigner, "btnPrintNow", "바로 인쇄", 645, 305, 100, 40, RGB(226, 239, 218), True AddButton formDesigner, "btnCreateNow", "파일 생성", 755, 305, 100, 40, RGB(226, 239, 218), True AddCheckBox formDesigner, "chkCreateFileNow", "바로 인쇄 시 파일도 생성", 635, 346, 205, 18 ' 3번 섹션 AddSectionBar formDesigner, "lblQueueSection", "3. 인쇄 대기 명단", 20, 370, 840, 25 AddLabel formDesigner, "lblQueue", "대기 명단 (0건)", 25, 405, 240, 20, 11, True AddLabel formDesigner, "lblQueueGuide", "※ 다수 스티커 발부 시 사용해 주세요.", 260, 405, 330, 20, 10, False, 1, -1, RGB(90, 90, 90) AddListBox formDesigner, "lstQueue", 25, 430, 830, 135 AddButton formDesigner, "btnRemove", "선택 삭제", 25, 575, 110, 30, RGB(242, 242, 242) AddButton formDesigner, "btnClear", "전체 삭제", 145, 575, 110, 30, RGB(242, 242, 242) ' 4번 섹션 AddSectionBar formDesigner, "lblOutputSection", "4. 인쇄 및 저장", 20, 620, 840, 25 AddLabel formDesigner, "lblSaveFolder", "저장 위치", 25, 663, 80, 20, 11, True AddTextBox formDesigner, "txtSaveFolder", 110, 660, 360, 32, False, True AddButton formDesigner, "btnSaveFolder", "폴더 변경", 480, 660, 80, 32, RGB(226, 239, 218) AddCheckBox formDesigner, "chkCreateFile", "인쇄 시 파일도 생성", 570, 665, 135, 25 AddButton formDesigner, "btnCreateFiles", "파일만 생성", 710, 660, 75, 36, RGB(221, 235, 247), True AddButton formDesigner, "btnPrint", "인쇄 실행", 790, 660, 65, 36, RGB(198, 224, 180), True AddLabel formDesigner, "lblCreator", "만든이: leekwangchan", 690, 705, 165, 18, 9, False, 3, -1, RGB(100, 100, 100) MsgBox "UserForm1 디자인 생성이 완료되었습니다.", vbInformation Exit Sub EH: MsgBox "알 수 없는 에러입니다: " & Err.Description, vbExclamation, "오류" End Sub Private Sub AddSectionBar(ByVal host As Object, ByVal cName As String, ByVal cText As String, ByVal L As Single, ByVal T As Single, ByVal W As Single, ByVal H As Single) AddLabel host, cName, cText, L, T, W, H, 11.5, True, 1, RGB(226, 239, 218) End Sub Private Sub AddLabel(ByVal host As Object, ByVal cName As String, ByVal cText As String, ByVal L As Single, ByVal T As Single, ByVal W As Single, ByVal H As Single, Optional ByVal fSize As Single = 10.5, Optional ByVal isBold As Boolean = False, Optional ByVal tAlign As Long = 1, Optional ByVal bgColor As Long = -1, Optional ByVal fColor As Long = 0) Dim ctl As Object: Set ctl = host.Controls.Add("Forms.Label.1", cName, True) ctl.Caption = cText: ctl.Left = L: ctl.Top = T: ctl.Width = W: ctl.Height = H ctl.Font.Name = "맑은 고딕": ctl.Font.Size = fSize: ctl.Font.Bold = isBold: ctl.TextAlign = tAlign: ctl.WordWrap = True: ctl.BackStyle = 0: ctl.ForeColor = fColor If bgColor >= 0 Then ctl.BackStyle = 1: ctl.BackColor = bgColor End Sub Private Sub AddTextBox(ByVal host As Object, ByVal cName As String, ByVal L As Single, ByVal T As Single, ByVal W As Single, ByVal H As Single, ByVal multi As Boolean, ByVal isLocked As Boolean) Dim ctl As Object: Set ctl = host.Controls.Add("Forms.TextBox.1", cName, True) ctl.Left = L: ctl.Top = T: ctl.Width = W: ctl.Height = H ctl.Font.Name = "맑은 고딕": ctl.Font.Size = 11: ctl.BackColor = IIf(isLocked, RGB(245, 245, 245), RGB(255, 255, 255)) ctl.BorderStyle = 1: ctl.SpecialEffect = 2: ctl.Locked = isLocked: ctl.TabStop = Not isLocked ' ★ 텍스트가 2줄로 접히게 세팅하되, Enter 치면 무조건 다음으로 넘어가게 수정했습니다! ctl.MultiLine = multi: ctl.WordWrap = multi ctl.EnterKeyBehavior = False ' 엔터키 줄바꿈 기능 강제 차단 (빠른 이동) If multi Then ctl.ScrollBars = 2 End Sub Private Sub AddComboBox(ByVal host As Object, ByVal cName As String, ByVal L As Single, ByVal T As Single, ByVal W As Single, ByVal H As Single) Dim ctl As Object: Set ctl = host.Controls.Add("Forms.ComboBox.1", cName, True) ctl.Left = L: ctl.Top = T: ctl.Width = W: ctl.Height = H ctl.Font.Name = "맑은 고딕": ctl.Font.Size = 11: ctl.BackColor = RGB(255, 255, 255) ctl.BorderStyle = 1: ctl.SpecialEffect = 2: ctl.TabStop = True End Sub Private Sub AddButton(ByVal host As Object, ByVal cName As String, ByVal cText As String, ByVal L As Single, ByVal T As Single, ByVal W As Single, ByVal H As Single, ByVal bgColor As Long, Optional ByVal isBold As Boolean = False) Dim ctl As Object: Set ctl = host.Controls.Add("Forms.CommandButton.1", cName, True) ctl.Caption = cText: ctl.Left = L: ctl.Top = T: ctl.Width = W: ctl.Height = H ctl.Font.Name = "맑은 고딕": ctl.Font.Size = 11: ctl.Font.Bold = isBold: ctl.BackColor = bgColor ctl.TabStop = False End Sub Private Sub AddListBox(ByVal host As Object, ByVal cName As String, ByVal L As Single, ByVal T As Single, ByVal W As Single, ByVal H As Single) Dim ctl As Object: Set ctl = host.Controls.Add("Forms.ListBox.1", cName, True) ctl.Left = L: ctl.Top = T: ctl.Width = W: ctl.Height = H ctl.Font.Name = "맑은 고딕": ctl.Font.Size = 10: ctl.BackColor = RGB(255, 255, 255): ctl.BorderStyle = 1: ctl.SpecialEffect = 2 ctl.IntegralHeight = False: ctl.ColumnCount = 7 ctl.ColumnWidths = "45 pt;60 pt;100 pt;310 pt;60 pt;60 pt;80 pt" ctl.TabStop = False End Sub Private Sub AddCheckBox(ByVal host As Object, ByVal cName As String, ByVal cText As String, ByVal L As Single, ByVal T As Single, ByVal W As Single, ByVal H As Single) Dim ctl As Object: Set ctl = host.Controls.Add("Forms.CheckBox.1", cName, True) ctl.Caption = cText: ctl.Left = L: ctl.Top = T: ctl.Width = W: ctl.Height = H ctl.Font.Name = "맑은 고딕": ctl.Font.Size = 10.5: ctl.BackColor = RGB(247, 250, 244) ctl.TabStop = False End Sub