snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Application
.CommandBars("Standard").Controls(24).Enabled = True
.CommandBars("View").Controls(11).Enabled = True
End With
End Sub
Private Sub Workbook_Open()
With Application
.CommandBars("Standard").Controls(24).Enabled = False
.CommandBars("View").Controls(11).Enabled = False
End With
End Sub
ลองดู Code ตามด้านล่าง วางไว้ใน ThisWorkbook ครับ เมื่อเปิดไฟล์ขึ้นมาจะทำให้เมนู Zoom จะไม่ทำงาน และจะทำงานเมื่อปิดไฟล์นี้ไปครับ
โค้ด: เลือกทั้งหมด
Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Application
.CommandBars("Standard").Controls(24).Enabled = True
.CommandBars("View").Controls(11).Enabled = True
End With
End Sub
Private Sub Workbook_Open()
With Application
.CommandBars("Standard").Controls(24).Enabled = False
.CommandBars("View").Controls(11).Enabled = False
End With
End Sub
ลองแล้วครับ
ยังไม่ work
ยังย่อ ขยายได้เหมือนเดิม
ตรงแถบเครื่องมือครับ
You do not have the required permissions to view the files attached to this post.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim i As Integer
With Application.CommandBars("Standard")
For i = 1 To .Controls.Count
If .Controls(i).Caption = "&Zoom:" Then
.Controls(i).Enabled = True
End If
Next i
End With
Application.CommandBars("View").Controls(11).Enabled = True
End Sub
Private Sub Workbook_Open()
Dim i As Integer
With Application.CommandBars("Standard")
For i = 1 To .Controls.Count
If .Controls(i).Caption = "&Zoom:" Then
.Controls(i).Enabled = False
End If
Next i
End With
Application.CommandBars("View").Controls(11).Enabled = False
End Sub
Sub Test()
Dim i As Integer
With Application.CommandBars("Standard")
For i = 1 To .Controls.Count
Cells(i, 1) = i
Cells(i, 2) = .Controls(i).Caption
Next i
End With
End Sub
You do not have the required permissions to view the files attached to this post.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim i As Integer
With Application.CommandBars("Standard")
For i = 1 To .Controls.Count
If .Controls(i).Caption = "&ย่อ/ขยาย:" Then
.Controls(i).Enabled = True
End If
Next i
End With
Application.CommandBars("View").Controls(11).Enabled = True
End Sub
Private Sub Workbook_Open()
Dim i As Integer
With Application.CommandBars("Standard")
For i = 1 To .Controls.Count
If .Controls(i).Caption = "&ย่อ/ขยาย:" Then
.Controls(i).Enabled = False
End If
Next i
End With
Application.CommandBars("View").Controls(11).Enabled = False
End Sub