現在我已經把word嵌到mfc中,對話框應用程式,也獲取到CCommandBars,但是要怎么去控制word中的 檔案 開始 審閱這一類的選單的使用?
求大神指導!!!!!!
uj5u.com熱心網友回復:
我自己頂 在線等大神回復uj5u.com熱心網友回復:
找個低版本的word,錄制宏,點擊選單操作,里面有相應的vb代碼uj5u.com熱心網友回復:
FindControl 方法請參閱 應用于 示例 特性
回傳一個符合指定條件的 CommandBarControl 物件。
expression.FindControl(Type, Id, Tag, Visible, Recursive)
expression 必需。該運算式回傳一個 CommandBars 物件。
Type MsoControlType 型別,可選。要查找的控制元件型別。
MsoControlType 型別可為以下 MsoControlType 常量之一:
msoControlActiveX
msoControlCustom
msoControlButton
msoControlEdit
msoControlDropdown
msoControlComboBox
msoControlButtonDropdown
msoControlSplitDropdown
msoControlGenericDropdown
msoControlGraphicCombo
msoControlSplitButtonMRUPopup
msoControlSplitExpandingGrid
msoControlGraphicDropdown
msoControlPopup
msoControlGraphicPopup
msoControlButtonPopup
msoControlGauge
msoControlLabel
msoControlExpandingGrid
msoControlGrid
msoControlOCXDropDown
msoControlSplitButtonPopup
msoControlPane
Id Variant 型別,可選。要查找的控制元件的識別符號。
Tag Variant 型別,可選。要查找的控制元件的標記值。
Visible Variant 型別,可選。如果該值為 True,那么只查找螢屏上顯示的命令欄控制元件。默認值為 False。螢屏上可見的命令欄,其中包括執行 FindControl 方法時所打開的所有可見的工具列和選單。
Recursive Boolean 型別,可選。如果該值為 True,那么將在命令欄及其全部彈出式子工具列中查找。此引數僅應用于 CommandBar 物件。默認值為 False。
說明
如果 CommandBars 集合中有兩個或者更多的控制元件符合搜索條件,那么 FindControl 回傳找到的第一個控制元件。如果沒有控制元件符合搜索條件,那么 FindControl 回傳 Nothing。
示例
本示例可實作的功能為:在命令欄“Custom”中查找第一個控制元件。如果該控制元件是按鈕,那么示例將用 FindControl 方法查找 Copy 按鈕(位于“常用”工具列上),然后復制 Copy 按鈕的圖符并粘貼到該控制元件上。
Set oldCtrl = CommandBars("Custom").Controls(1)
If oldCtrl.Type = 1 Then
Set newCtrl = CommandBars.FindControl(Type:= _
MsoControlButton, ID:= _
CommandBars("Standard").Controls("Copy").ID)
NewCtrl.CopyFace
OldCtrl.PasteFace
End If
全部顯示
CommandBarButton 物件
請參閱 屬性 方法 事件 特性
CommandBars (CommandBar)
CommandBarControls (CommandBarControl)
CommandBarButton
CommandBarComboBox
CommandBarPopup
代表命令欄中的一個按鈕控制元件。
使用 CommandBarButton 物件
用 Controls(index) 可回傳一個 CommandBarButton 物件;此處 index 是該控制元件的索引號。(該控制元件的 Type 屬性必須是 msoControlButton。)
假定命令欄“Custom”中的第二個控制元件是一個按鈕,以下示例更改該按鈕的樣式。
Set c = CommandBars("Custom").Controls(2)
With c
If .Type = msoControlButton Then
If .Style = msoButtonIcon Then
.Style = msoButtonIconAndCaption
Else
.Style = msoButtonIcon
End If
End If
End With
用 FindControl 方法也可回傳一個 CommandBarButton 物件。
Visible 屬性
請參閱 應用于 示例 特性
本主題中的某些內容可能不適用于某些語言。
如果指定物件可見,則回傳 True。Boolean 型別,可讀寫。
expression.Visible
expression 必需。該運算式回傳“應用于”串列中的物件之一。
說明
新建自定義命令欄的 Visible 屬性的默認值為 False。
只有先將命令欄的 Enabled 屬性設定為 True,才可將其 Visible 屬性設定為 True。
示例
本示例可實作的功能為:逐個檢查命令欄集合中的成員,以找到“Forms”命令欄。如果找到該命令欄,那么顯示該命令欄并保護其定位狀態。
foundFlag = False
For Each cmdbar In CommandBars
If cmdbar.Name = "Forms" Then
cmdbar.Protection = msoBarNoChangeDock
cmdbar.Visible = True
foundFlag = True
End If
Next
If Not foundFlag Then
MsgBox "'Forms'command bar is not in the collection."
End If
本示例可顯示“Office 助手”并設定其動態效果型別。
With Application.Assistant
.Visible = True
.Sounds = True
.Animation = msoAnimationBeginSpeaking
End With
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/101183.html
上一篇:win10系統下用VS2015開發人員命令提示配置Open SSL出現以下問題
下一篇:VS2010用MFC撰寫對話框
