国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

對(duì) Microsoft Office 命令欄進(jìn)行更多編程(3)

2024-07-21 02:23:56
字體:
供稿:網(wǎng)友
commandbardocumenter 和 commandbarcontroldocumenter 子例程
在開發(fā)命令欄解決方案時(shí),我經(jīng)常需要獲取特定命令欄或命令欄控件的索引、名稱或標(biāo)題。我創(chuàng)建了 commandbardocumenter 和 commandbarcontroldocumenter 子例程,以便將所有命令欄和命令欄控件的公共屬性記錄在給定的 office 應(yīng)用程序中。

要運(yùn)行這些示例,請(qǐng)?jiān)?visual basic editor 中將以下代碼復(fù)制到 microsoft office xp 應(yīng)用程序的代碼模塊,然后運(yùn)行以下子例程之一或兩者都運(yùn)行。屏幕出現(xiàn)提示時(shí),請(qǐng)將結(jié)果保存為文本文件 (.txt)。這使結(jié)果更容易加載到應(yīng)用程序(例如 microsoft excel)中以便查看和過濾。

public sub commandbardocumenter()

    ' 用途:將當(dāng)前應(yīng)用程序中有關(guān)所有命令欄的信息
    ' 寫入文本文件。
    
    ' 您必須先設(shè)置對(duì) microsoft 腳本運(yùn)行時(shí)的引用
    ' (scrrun.dll) 才能使此代碼正確運(yùn)行。
    
    ' 注意:此代碼僅適用于 microsoft office xp。
    
    dim objcommandbar as office.commandbar
    dim strtype as string
    dim strposition as string
    dim objfilesavedialog as office.filedialog
    dim objfso as scripting.filesystemobject
    dim objtextstream as scripting.textstream
    const save_button as integer = -1
    
    set objfilesavedialog = application.filedialog(msofiledialogsaveas)
    
    objfilesavedialog.title = "將結(jié)果另存為"
    
    ' 用戶單擊“保存”按鈕。
    if objfilesavedialog.show = save_button then
     
        set objfso = new scripting.filesystemobject
        set objtextstream = objfso.createtextfile(objfilesavedialog.selecteditems.item(1))
        

        objtextstream.writeline "name" & vbtab & _
            "type" & vbtab & _
            "enabled" & vbtab & _
            "visible" & vbtab & _
            "index" & vbtab & _
            "position" & vbtab & _
            "protection" & vbtab & _
            "row index" & vbtab & _
            "top" & vbtab & _
            "height" & vbtab & _
            "left" & vbtab & _
            "width"
        
        ' 將下一行替換為:
        ' for each objcommandbar in application.activeexplorer.commandbars _
           <- 對(duì)于 outlook
        ' for each objcommandbar in application.vbe.commandbars <- 對(duì)于 _
            visual basic editor
        for each objcommandbar in application.commandbars
    

            select case objcommandbar.type
                case msobartypemenubar
                    strtype = "menu bar"
                case msobartypenormal
                    strtype = "normal"
                case msobartypepopup
                    strtype = "pop-up"
            end select
        
            select case objcommandbar.position
                case msobarbottom
                    strposition = "bottom"
                case msobarfloating
                    strposition = "floating"
                case msobarleft
                    strposition = "left"
                case msobarmenubar
                    strposition = "menu bar"
                case msobarpopup
                    strposition = "pop-up"
                case msobarright
                    strposition = "right"
                case msobartop
                    strposition = "top"
            end select
        
            select case objcommandbar.protection
                case msobarnochangedock
                    strprotection = "no change dock"
                case msobarnochangevisible
                    strprotection = "no change visible"
                case msobarnocustomize
                    strprotection = "no customize"
                case msobarnohorizontaldock
                    strprotection = "no horizontal dock"
                case msobarnomove
                    strprotection = "no move"
                case msobarnoprotection
                    strprotection = "no protection"
                case msobarnoresize
                    strprotection = "no resize"
                case msobarnoverticaldock
                    strprotection = "no vertical dock"
            end select
            
            objtextstream.writeline objcommandbar.name & vbtab & _
                strtype & vbtab & _
                objcommandbar.enabled & vbtab & _
                objcommandbar.visible & vbtab & _
                objcommandbar.index & vbtab & _
                strposition & vbtab & _
                strprotection & vbtab & _
                objcommandbar.rowindex & vbtab & _
                objcommandbar.top & vbtab & _
                objcommandbar.height & vbtab & _
                objcommandbar.left & vbtab & _
                objcommandbar.width
            
        next objcommandbar
    
        objtextstream.close
        
        msgbox "結(jié)果寫入 " & objfilesavedialog.selecteditems.item(1) & "."
    
    end if
    
end sub

sub commandbarcontroldocumenter()

    ' 用途:將當(dāng)前應(yīng)用程序中所有有關(guān)命令欄的信息
    ' 寫入文本文件。

    ' 您必須先設(shè)置對(duì) microsoft 腳本運(yùn)行時(shí)的引用
    ' 才能使此代碼正確運(yùn)行。
    
    ' 注意:此代碼僅適用于 microsoft office xp。

    dim objcommandbar as office.commandbar
    dim objcommandbarcontrol as office.commandbarcontrol
    dim stroleusage as string
    dim strtype as string
    dim objfilesavedialog as office.filedialog
    dim objfso as scripting.filesystemobject
    dim objtextstream as scripting.textstream
    const save_button as integer = -1
    
    set objfilesavedialog = application.filedialog(msofiledialogsaveas)
    
    objfilesavedialog.title = "將結(jié)果另存為"
    
    ' 用戶單擊“保存”按鈕。
    if objfilesavedialog.show = save_button then
     
        set objfso = new scripting.filesystemobject
        set objtextstream = objfso.createtextfile(objfilesavedialog.selecteditems.item(1))
        
        objtextstream.writeline "id" & vbtab & _
            "index" & vbtab & _
            "caption" & vbtab & _
            "parent" & vbtab & _
            "descriptiontext" & vbtab & _
            "builtin" & vbtab & _
            "enabled" & vbtab & _
            "isprioritydropped" & vbtab & _
            "oleusage" & vbtab & _
            "priority" & vbtab & _
            "tag" & vbtab & _
            "tooltiptext" & vbtab & _
            "type" & vbtab & _
            "visible" & vbtab & _
            "height" & vbtab & _
            "width"
    
            ' 將下一行替換為:
            ' for each objcommandbar in application.activeexplorer.commandbars <- 對(duì)于 outlook
            ' for each objcommandbar in application.vbe.commandbars _
                <- 對(duì)于 visual basic editor
            for each objcommandbar in application.commandbars
            
                for each objcommandbarcontrol in objcommandbar.controls
                
                    select case objcommandbarcontrol.oleusage
                        

                        case msocontrololeusageboth
                            stroleusage = "both"
                        case msocontrololeusageclient
                            stroleusage = "client"
                        case msocontrololeusageneither
                            stroleusage = "neither"
                        case msocontrololeusageserver
                            stroleusage = "server"
                    
                    end select
                
                    select case objcommandbarcontrol.type
                    
                        case msocontrolactivex
                            strtype = "activex"
                        case msocontrolautocompletecombo
                            strtype = "auto-complete combo box"
                        case msocontrolbutton
                            strtype = "button"
                        case msocontrolbuttondropdown
                            strtype = "drop-down button"
                        case msocontrolbuttonpopup
                            strtype = "popup button"
                        case msocontrolcombobox
                            strtype = "combo box"
                        case msocontrolcustom
                            strtype = "custom"
                        case msocontroldropdown
                            strtype = "drop-down"
                        case msocontroledit
                            strtype = "edit"
                        case msocontrolexpandinggrid
                            strtype = "expanding grid"
                        case msocontrolgauge
                            strtype = "gauge"
                        case msocontrolgenericdropdown
                            strtype = "generic drop-down"
                        case msocontrolgraphiccombo
                            strtype = "graphic combo box"
                        case msocontrolgraphicdropdown
                            strtype = "graphic drop-down"
                        case msocontrolgraphicpopup
                            strtype = "popup graphic"
                        case msocontrolgrid
                            strtype = "grid"
                        case msocontrollabel
                            strtype = "label"
                        case msocontrollabelex
                            strtype = "labelex"
                        case msocontrolocxdropdown
                            strtype = "ocx drop-down"
                        case msocontrolpane
                            strtype = "pane"
                        case msocontrolpopup
                            strtype = "popup"
                        case msocontrolspinner
                            strtype = "spinner"
                        case msocontrolsplitbuttonmrupopup
                            strtype = "split button mru popup"
                        case msocontrolsplitbuttonpopup
                            strtype = "button popup"
                        case msocontrolsplitdropdown
                            strtype = "split drop-down"
                        case msocontrolsplitexpandinggrid
                            strtype = "split expanding grid"
                        case msocontrolworkpane
                            strtype = "work pane"
            
                        end select
                            
                        objtextstream.writeline objcommandbarcontrol.id & _
                          vbtab & _
                            objcommandbarcontrol.index & vbtab & _
                            objcommandbarcontrol.caption & vbtab & _
                            objcommandbarcontrol.parent.name & vbtab & _
                            objcommandbarcontrol.descriptiontext & vbtab & _
                            objcommandbarcontrol.builtin & vbtab & _
                            objcommandbarcontrol.enabled & vbtab & _
                            objcommandbarcontrol.isprioritydropped & vbtab & _
                            stroleusage & vbtab & _
                            objcommandbarcontrol.priority & vbtab & _
                            objcommandbarcontrol.tag & vbtab & _
                            objcommandbarcontrol.tooltiptext & vbtab & _
                            strtype & vbtab & _
                            objcommandbarcontrol.visible & vbtab & _
                            objcommandbarcontrol.height & vbtab & _
                            objcommandbarcontrol.width
                                                    
                    next objcommandbarcontrol
                
                next objcommandbar
                
                objtextstream.close
        
                msgbox "結(jié)果寫入 " & _
                  objfilesavedialog.selecteditems.item(1) & "."
    
            end if
            
end sub


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 米脂县| 霍邱县| 宜宾县| 富平县| 宁化县| 曲麻莱县| 五家渠市| 益阳市| 阿尔山市| 北安市| 饶平县| 昔阳县| 金阳县| 抚顺县| 甘孜县| 杂多县| 司法| 卓资县| 农安县| 土默特左旗| 罗田县| 中方县| 鹿邑县| 固阳县| 汝阳县| 新乐市| 武城县| 尖扎县| 金塔县| 泾阳县| 福贡县| 三门县| 南丰县| 旺苍县| 贵州省| 南木林县| 石屏县| 乌拉特中旗| 牡丹江市| 青海省| 鹤壁市|