Chia sẻ công cụ tạo Ribbon cho file Excel

Liên hệ QC

huuthang_bd

Chuyên gia GPE
Tham gia
10/9/08
Bài viết
8,709
Được thích
10,814
Donate (Momo)
Donate
Giới tính
Nam
Nghề nghiệp
Thợ đụng
Xuất phát từ ý tưởng của topic Add-Ins Tạo Menu RibbonTiếng Việt Có Dấu Cho Office
Tôi viết lại công cụ tạo Ribbon cho file Excel. Vì topic kia đã quá nhiều bài nên tôi mở topic này để mọi người dễ tìm hơn.
Ai cần thì tải về dùng. "Open source" --=0
 

File đính kèm

  • Ribbon Creator.rar
    439.7 KB · Đọc: 1,129
Trong file đã xóa hết code.
Còn đây là toàn bộ code tạo Ribbon trong file của bạn

HTML:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="UX_onLoad">
<!--For Office 2007, use 2006/01 instead of 2009/07-->

    <commands>
        <command idMso="Help" enabled="false"/>
        <command idMso="WindowClose" enabled="true"/>
        <command idMso="WindowRestore" enabled="true"/>
        <command idMso="WindowMinimize" enabled="true"/>
    </commands>

    <ribbon startFromScratch="false">
        <tabs>
            <tab idMso="TabHome" getVisible="UX_Visible"/>
            <tab idMso="TabInsert" getVisible="UX_Visible"/>
            <tab idMso="TabPageLayoutExcel" getVisible="UX_Visible"/>
            <tab idMso="TabFormulas" getVisible="UX_Visible"/>
            <tab idMso="TabData" getVisible="UX_Visible"/>
            <tab idMso="TabReview" getVisible="UX_Visible"/>
            <tab idMso="TabView" getVisible="UX_Visible"/>
            <tab idMso="TabDeveloper" getVisible="UX_Visible"/>
            <tab idMso="TabAddIns" getVisible="UX_Visible"/>
            <!-- tab idMso="TabPrintPreview" getVisible="UX_Visible"/ -->
<tab id="TAB400" getLabel="UX_Label" insertBeforeMso='TabHome' getKeytip="UX_Keytip" getVisible="UX_Visible">
<group id="GRP420" autoScale="false" getLabel="UX_Label" centerVertically="false" getVisible="UX_Visible" imageMso="ConnectedToolSyncMenu">
    <toggleButton id="CTL421" size="large" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_ActionTgl" imageMso="ConnectedToolSyncMenu" getPressed="UX_PressTgl"/>
    <checkBox id="CTL422" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_ActionTgl" getPressed="UX_PressTgl"/>
    <checkBox id="CTL423" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_ActionTgl" getPressed="UX_PressTgl"/>
    <checkBox id="CTL424" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_ActionTgl" getPressed="UX_PressTgl"/>
</group>

<group id="GRP120" autoScale="false" getLabel="UX_Label" centerVertically="false" getVisible="UX_Visible" imageMso="ViewGoForward">

<gallery id="GLR1111" size="large" getLabel="UX_Label" onAction="OnActionGLR" imageMso="TasksUpdate">
    <button id="BTN1110" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="AccessTableContacts"/>
    <button id="BTN1116" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="AddOrRemoveAttendees"/>
    <button id="BTN1115" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ResourceUsageViewGallery"/>

       <button id="BTN1101" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                     
    <button id="BTN1102" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                   
    <button id="BTN1103" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                   
    <button id="BTN1104" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>

       <button id="BTN11111" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                     
    <button id="BTN11112" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                   
    <button id="BTN11113" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                   
    <button id="BTN11114" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>   
    <button id="BTN11115" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                   
    <button id="BTN11116" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                   
    <button id="BTN11117" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                             
</gallery>
    <button id="BTN1201" size="large" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="CreateReportFromWizard"/>
    <button id="BTN1202" size="large" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewWorkflowReports"/>

</group>

<!--*******************************************************************-->

<group id="GRP520" autoScale="false" getLabel="UX_Label" centerVertically="false" getVisible="UX_Visible" imageMso="ViewGoForward">
    <button id="BTN5201" size="large" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="CalendarMonthDetailsSplitButton"/>
<gallery id="GLR120" size="large" getLabel="UX_Label" onAction="OnActionGLR" imageMso="VersionsAndCheckout">
    <button id="BTN5202" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="GroupWindowAccess"/>
        <button id="BTN1211" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                     
    <button id="BTN1212" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                   
    <button id="BTN1213" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                   
    <button id="BTN1214" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/> 
        <button id="BTN1215" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                     
    <button id="BTN1216" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                   
    <button id="BTN1217" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                   
    <button id="BTN1218" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                               
</gallery>
</group>

<group id="GRP510" autoScale="false" getLabel="UX_Label" centerVertically="false" getVisible="UX_Visible" imageMso="ViewGoForward">
    <button id="BTN51011" size="large" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="CatalogMergeEditList"/>
<gallery id="GLR510" size="large" getLabel="UX_Label" onAction="OnActionGLR" imageMso="AddressBook">
    <button id="BTN51012" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="GroupResourceViewSimple"/>
    <button id="BTN51013" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="BusinessCardInsertMenu"/>
       <button id="BTN5111" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                     
    <button id="BTN5112" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                   
    <button id="BTN5113" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/>                                   
    <button id="BTN5114" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ViewGoForward"/> 
</gallery>
</group>

<group id="GRP610" autoScale="false" getLabel="UX_Label" centerVertically="false" getVisible="UX_Visible" imageMso="LocalShareNotebook">
<gallery id="GLR620" size="large" getLabel="UX_Label" onAction="OnActionGLR" imageMso="LocalShareNotebook">
      <button id="BTN1203" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" image="vat"/>
    <button id="BTN1204" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="GoRtlDown"/>
    <button id="BTN1205" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="GoLtrDown"/>

    <button id="BTN6110" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="LocalShareNotebook"/>
    <button id="BTN6111" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="JapanesePostcardDialog"/>
    <button id="BTN6112" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="JapanesePostcardCreateAddressSide"/>

    <button id="BTN6201" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="CreateReport"/>
    <button id="BTN6202" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="FunctionsDateTimeInsertGallery"/>
    <button id="BTN6203" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="GroupProjectSchedule"/>
    <button id="BTN6204" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="BusinessFormWizard"/>

        <button id="BTN6211" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="OutlineDemoteToBodyText"/>                                     
    <button id="BTN6212" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="OutlineDemoteToBodyText"/>                                   
    <button id="BTN6213" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="OutlineDemoteToBodyText"/>                                                               
</gallery>

<gallery id="GRP540" size="large" getLabel="UX_Label" onAction="OnActionGLR" imageMso="AddResourcesFromActiveDirectory">
    <button id="CTL5401" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="AddResourcesFromActiveDirectory"/>
    <button id="CTL5402" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ResourceAllViewsGallery"/>
    <button id="CTL5403" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="AnonymousAccess"/>
    <button id="BTN6217" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="OutlineDemoteToBodyText"/>                                   
    <button id="BTN6218" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="OutlineDemoteToBodyText"/>
    <button id="BTN6216" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="OutlineDemoteToBodyText"/> 
</gallery>
<gallery id="GRP5430" size="large" getLabel="UX_Label" onAction="OnActionGLR" imageMso="MenuDailyTaskList">
      <button id="CTL5431" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="MenuDailyTaskList"/>
    <button id="CTL5432" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="MaterialResourceInsert"/>
    <button id="CTL5433" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="HappyFace"/>
    <button id="BTN6214" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="OutlineDemoteToBodyText"/> 
        <button id="BTN6215" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="OutlineDemoteToBodyText"/>
</gallery>

</group>
<group id="GRP5450" autoScale="false" getLabel="UX_Label" centerVertically="false" getVisible="UX_Visible" imageMso="ViewGoForward">
<gallery id="GRP5456" size="large" getLabel="UX_Label" onAction="OnActionGLR" imageMso="GanttChartViewGallery">
      <button id="CTL5451" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="AddContentType"/>
      <button id="CTL5452" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="WorkflowComplete"/>
    <button id="CTL5453" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="WorkflowComplete"/>
    <button id="CTL5454" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="WorkflowComplete"/>
    <button id="CTL5455" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ContactCardUntagForAlerts"/>
</gallery>

<gallery id="GLR680" size="large" getLabel="UX_Label" onAction="OnActionGLR" imageMso="ChangePictureFromScanner">
    <button id="CTL6702" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="WorkflowComplete"/>
    <button id="CTL6703" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="WorkflowComplete"/>
    <button id="CTL6705" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="WorkflowComplete"/>
    <button id="CTL6706" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="WorkflowComplete"/>

    <button id="CTL6704" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ContactCardUntagForAlerts"/>
    <button id="CTL6701" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="ChangePictureFromScanner"/>

        <button id="BTN6811" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="OutlineDemoteToBodyText"/>                                     
    <button id="BTN6812" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="OutlineDemoteToBodyText"/>                                   
    <button id="BTN6813" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="OutlineDemoteToBodyText"/>                                   
    <button id="BTN6814" getLabel="UX_Label" getVisible="UX_Visible" getEnabled="UX_Enabled" onAction="UX_Action" imageMso="OutlineDemoteToBodyText"/>                                                 
</gallery>
</group>

<!--*******************************************************************-->


</tab>
        </tabs>
    </ribbon>
</customUI>
thật ra thì code trong file nay em cũng đã xem được rồi, chỉ thắc mắc một điều là code của module bị xóa hết hay là chỉ bị ẩn đi thì em không rõ nhưng các ribbon này vẫn hoạt động bình thường và các form dùng code của module cũng vẫn hoạt động ạ. em dùng project explorer thì thấy có những module đó nhưng không hề thấy nó. và cũng không mở được. nếu nó bị xóa rồi thì làm sao các code đó vẫn hoạt động nhỉ221579
 
Upvote 0
Mã:
Private Sub nhaplieu(Ctrl As IRibbonControl)
Sheet5.Visible = xlSheetVisible
Sheet5.Select
End Sub
Private Sub cdps(Ctrl As IRibbonControl)
Sheet6.Visible = xlSheetVisible
Sheet6.Select
End Sub
Private Sub cdkt(Ctrl As IRibbonControl)
Sheet7.Visible = xlSheetVisible
Sheet7.Select
End Sub
Private Sub kqkd(Ctrl As IRibbonControl)
Sheet8.Visible = xlSheetVisible
Sheet8.Select
End Sub
Private Sub lctt(Ctrl As IRibbonControl)
Sheet9.Visible = xlSheetVisible
Sheet9.Select
End Sub
Private Sub tmbctc(Ctrl As IRibbonControl)
Sheet10.Visible = xlSheetVisible
Sheet10.Select
End Sub
nhờ anh chị giúp. em có dùng mã như trên để gán vào cho từng mục trên ribbon để di chuyển giữa các sheet nhưng số lượng sheet nhiều. có cách nào để tối ưu được mã này không ạ.
 
Upvote 0
Bạn có thể đặt tên của button là tên sheet và dùng code sau cho tất cả các button.
Mã:
Private Sub SelectSheet(Ctrl As IRibbonControl)
Sheets(Ctrl.ID).Visible = xlSheetVisible
Sheets(Ctrl.ID).Select
End Sub
 
Upvote 0
Bạn có thể đặt tên của button là tên sheet và dùng code sau cho tất cả các button.
Mã:
Private Sub SelectSheet(Ctrl As IRibbonControl)
Sheets(Ctrl.ID).Visible = xlSheetVisible
Sheets(Ctrl.ID).Select
End Sub
sao em đã thay ID của button bằng tên sheet rồi mà nó k chạy nhỉ. ví dụ sheet 5 là NLPS thì ID em để là NLPS hay là Sheet5 thì đều không được ạ.
 
Upvote 0
Upvote 0
dạ đây ạ. em đang làm theo như này ạ
- Trong nội dung XML có onLoad nhưng trong Module1 không có Sub OnLoad nên sẽ có lỗi và không có menu.

- Trong nội dung XML không có onAction nào được gán cho 3 nút "Nhập liệu", "Bảng cân đối", "Tổng hợp". Vì thế thậm chí nếu thêm Sub OnLoad thì khi nhấn vào 3 nút trên thì không thấy động tĩnh gì. Dụng ý dùng 3 nút kia chỉ để trang trí?

- Trong nội dung XML không có nút nào có onAction là SelectSheet, vậy nó có chỉ để làm vì?
------------
để di chuyển giữa các sheet nhưng số lượng sheet nhiều
Chả nhẽ tạo 20, 30 nút khi số sheet là vd. 20, 30? Nếu chỉ tạo 1 nút thì trong onAction của nó phải hiển thị vd. UserForm mà trên đó có 1 ComboBox với danh sách các sheet. Khi chọn sheet nào trong ComboBox thì hiển thị sheet đó. Nhưng sao lại phải tạo nút + UserForm + ComboBox? Thay cho tạo nút thì tạo ComboBox trên ribbon thôi. ComboBox đó sẽ có danh sách các sheet. Khi chọn sheet nào trong ComboBox thì hiển thị sheet đó. Thế thôi.

Trên đây chỉ là các lưu ý và gợi ý. Tôi không làm cho bạn vì tuy không mở Ribbon Creator.xlsm nhưng tôi đoán là nó dùng để tạo menu trên ribbon. Mà tôi thì không có hứng nghiên cứu cách dùng phần mềm thứ ba. Tôi tự tạo nội dung XML + dùng Custom UI Editor thôi.
 
Upvote 0
c
- Trong nội dung XML có onLoad nhưng trong Module1 không có Sub OnLoad nên sẽ có lỗi và không có menu.

- Trong nội dung XML không có onAction nào được gán cho 3 nút "Nhập liệu", "Bảng cân đối", "Tổng hợp". Vì thế thậm chí nếu thêm Sub OnLoad thì khi nhấn vào 3 nút trên thì không thấy động tĩnh gì. Dụng ý dùng 3 nút kia chỉ để trang trí?

- Trong nội dung XML không có nút nào có onAction là SelectSheet, vậy nó có chỉ để làm vì?
------------

Chả nhẽ tạo 20, 30 nút khi số sheet là vd. 20, 30? Nếu chỉ tạo 1 nút thì trong onAction của nó phải hiển thị vd. UserForm mà trên đó có 1 ComboBox với danh sách các sheet. Khi chọn sheet nào trong ComboBox thì hiển thị sheet đó. Nhưng sao lại phải tạo nút + UserForm + ComboBox? Thay cho tạo nút thì tạo ComboBox trên ribbon thôi. ComboBox đó sẽ có danh sách các sheet. Khi chọn sheet nào trong ComboBox thì hiển thị sheet đó. Thế thôi.

Trên đây chỉ là các lưu ý và gợi ý. Tôi không làm cho bạn vì tuy không mở Ribbon Creator.xlsm nhưng tôi đoán là nó dùng để tạo menu trên ribbon. Mà tôi thì không có hứng nghiên cứu cách dùng phần mềm thứ ba. Tôi tự tạo nội dung XML + dùng Custom UI Editor thôi.
em cảm ơn bác ạ. em đã hiểu ra rồi ạ. cần phải gán onAction là SelectSheet cho button thì đã chạy được rồi ạ.
 
Upvote 0
Bạn có thể đặt tên của button là tên sheet và dùng code sau cho tất cả các button.
Mã:
Private Sub SelectSheet(Ctrl As IRibbonControl)
Sheets(Ctrl.ID).Visible = xlSheetVisible
Sheets(Ctrl.ID).Select
End Sub
em có phát sinh thêm một vấn đề là nếu như cùng 2 button ở 2 tab khác nhau muốn đến 1 sheets thì lại không dùng code này được. bác giúp em sửa lại được không ạ. (vì em muốn thêm một vài sheet hay dùng sang tab home ạ.)
 
Lần chỉnh sửa cuối:
Upvote 0
em có phát sinh thêm một vấn đề là nếu như cùng 2 button ở 2 tab khác nhau muốn đến 1 sheets thì lại không dùng code này được. bác giúp em sửa lại được không ạ. (vì em muốn thêm một vài sheet hay dùng sang tab home ạ.)
Nếu vậy thì bạn sử dụng thuộc tính Tag thay cho ID, ID phải duy nhất còn Tag thì không. Đặt thuộc tính Tag của control là tên sheet, code trong VBA chỗ nào là ID thì thay bằng Tag.
 
Upvote 0
Anh giúp đỡ em: Em tạo menu có 3 nút button (tạo mới, hủy, lưu). Khi mở file, nút Hủy với lưu sẽ ẩn (hoặc đóng băng). Kích vào nút tạo mới thì 2 nút còn lại sẽ hiện và nút tạo mới đóng băng. Nhờ anh hướng dẫn với. Cảm ơn anh.
 
Upvote 0
Anh giúp đỡ em: Em tạo menu có 3 nút button (tạo mới, hủy, lưu). Khi mở file, nút Hủy với lưu sẽ ẩn (hoặc đóng băng). Kích vào nút tạo mới thì 2 nút còn lại sẽ hiện và nút tạo mới đóng băng. Nhờ anh hướng dẫn với. Cảm ơn anh.
Bạn tham khảo file này.
 

File đính kèm

  • GPE.xlsm
    13.4 KB · Đọc: 80
Upvote 0
Nhờ anh xem, sao excel mở file bình thường thôi, file tạo mới nhưng kích chuột phải như hình.

PS. đã khắc được.
Mã:
Sub reset()

Application.CommandBars("Cell").Reset

End Sub
Nhưng nhờ anh xem sao lại bị lỗi như vậy
 

File đính kèm

  • anh loi.jpg
    anh loi.jpg
    270.5 KB · Đọc: 42
Lần chỉnh sửa cuối:
Upvote 0
bạn ơi cho hoi bài nào dạy cách tạo ribbon vậy. Thấy hay quá mà chưa biết tạo sao
 
Upvote 0
Em đã tắt macro nhưng khi mở file lên vẫn có tag ribbon mới (các button trên tag ribbon mới không sữ dụng được) chỉ mỗi file đó còn những file khác mở lên sẽ không thấy tag riboon mới.
 
Upvote 0
Em đã tắt macro nhưng khi mở file lên vẫn có tag ribbon mới (các button trên tag ribbon mới không sữ dụng được) chỉ mỗi file đó còn những file khác mở lên sẽ không thấy tag riboon mới.
Tắt macro nhưng vẫn thấy ribbon là bình thường. Ribbon có sử dụng được hay không là do code của bạn. Tóm lại bạn muốn xóa ribbon hay thế nào?
 
Upvote 0
Web KT
Back
Top Bottom