Filed under: Office 2007學習筆記, Top

圓戳章-增益集-Excel 2007版

by chijanzen on 一月 6th, 2010 | View: 6,388 views

Tags
  • No Tags
Share Comments (3)
索   引 Office 2007 筆記
主   題 圓戳章-增益集-版本更新適用2007、2010版
版   本 >= 12.0(Office 2007)
說   明

經過大約10天的摸索學習對於Ribbon(功能區 ) XML 檔語法也有一定的認識,接著就開始進入實戰訓練了(加油!),這次目標是將 圓戳章-增益集 轉換為 2007版增益集,以下將轉換的過程記錄下來....

參   考

  • 先來解說 XML 檔,以下為本範例的XML語法
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<!-- Add Custom group to the Home tab in the ribbon-->
<ribbon>
<tabs>
<tab idMso="TabInsert" >
<group id="sealGroup1" label="chijanzen Tools"
insertBeforeMso="GroupEditing" >
<button id="rxSealbtn1" label="圓戳章" image="seal"
size="large" onAction="Callseal" />
<button id="rxSealbtn2" label="選項" imageMso="ControlSetControlDefaults"
size="large" onAction="Callsealoption" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
  • 從下圖就可以看出<ribbon>、<tabs>、<tab>、<group>、<button>的附屬關析
  • 上次文章 Ribbon(功能區 ) 說明中我有整理 出 Ribbon 索引標籤與 XML 標籤名稱的對照表,
  • 我要在 「插入」(TabInsert )索引標籤內新增2個按鈕,所以語法為 
      <tab idMso="TabInsert" >
<group id="sealGroup1" label="chijanzen Tools"
   insertBeforeMso="GroupEditing" >

Ribbon 索引標籤

XML 標籤名稱

常用 TabHome
插入 TabInsert
版面配置 TabPageLayoutExcel
公式 TabFormulas
資料 TabData
校閱 TabReview
檢視 TabView
開發 TabDeveloper
增益集 TabAddIns

  • 建立好群組(group)後,我在群組(group)內新增2個按紐(button),語法如下

          <button id="rxSealbtn1" label="圓戳章" image="seal"
                  size="large" onAction="Callseal" />
          <button id="rxSealbtn2" label="選項" imageMso="ControlSetControlDefaults"
                  size="large" onAction="Callsealoption"
/>
 

  • 第一個按鈕 圓戳章 使用自訂的圖示 image="seal"  ,要如何插入自定圖示請參考 Custom UI Editor Tool

  • 第二個按鈕 選項 使用Excel 自帶的圖示 imageMso="ControlSetControlDefaults" , 要如何知道Excel 自帶圖示樣式及名稱,

請下載 http://www.rondebruin.nl/files/BtnImages.zip

  • XML 檔語法寫好後,使用 Custom UI Editor Tool  將 XML 檔存入增益集中。
  • 製作完 XML 檔,開始寫 Callback (回乎)程式,程式碼如下

'Callback for rxSealbtn1 onAction
Sub Callseal(control As IRibbonControl)
Dim seal_shp As Shape, actRng As Range
Dim Item As Object
    On Error Resume Next
    If ThisWorkbook.Sheets("IconSheet").Range("Z1") <> "chijanzen" Then
        MsgBox "歡迎使用圓形章程式,第一次使用本程式需作基本資料設定"
        sealForm.Show 0
        Exit Sub
    End If
    '插入圓戳章
    On Error Resume Next
    '刪除已存在的圓戳章
    Set seal_shp = ActiveSheet.Shapes("icon")
    If Not seal_shp Is Nothing Then seal_shp.Delete
    '插入圓戳章(日期為當日)
    Set actRng = ActiveCell
    With ThisWorkbook.Sheets("IconSheet").Shapes("icon")
        .GroupItems.Item(6).TextEffect.Text = Format(Date, "Yyyy/m/d")
        .Copy
        ActiveSheet.Paste
    End With
    actRng.Activate
End Sub
 


'Callback for rxSealbtn2 onAction
Sub Callsealoption(control As IRibbonControl)
    sealForm.Show 0
End Sub
 

  • 圓戳章-增益集-Excel 2007版 檔案下載檔案下載

  • 安裝說明:

  附件內有兩個檔案,請解壓縮到同一資料夾內,請執行Install 按鈕安裝程式

 

  VBE 密碼:chijanzen

 

Popularity: 34%

About the Author
    網路化名: chijanzen、中國龍、邪兵衛 經歷: 第二屆微軟社群之星 第三屆微軟「最有價值專家」 第五屆微軟「最有價值專家」
Leave a Comment »3 Comments
  • Reply » sjoo 三月 25, 2009

    excellent, thank to your this post , i solved out VBA error related to OnAction. thank yolu again

  • Reply » wang 九月 21, 2008

    這個版本修正了日期的問題了
    謝謝~~

Get a GravatarLeave a Reply

Name: « Required

Email Address: « Required

Website URL: « Optional

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

About me
chijanzen 分享個人Excel VBA 學習經驗,架站心得, 日常生活記事等...

Add to Google

分類
Translator
Chinese (Simplified) flagItalian flagKorean flagEnglish flagGerman flag
French flagJapanese flagRussian flagBulgarian flagFinnish flag
相簿