Visio (的 Window.BackgroundColor 属性)

會決定使用中 Microsoft Visio 繪圖視窗及其關聯的預覽列印和全螢幕檢視視窗的背景色彩。 讀取/寫入。

語法

expressionBackgroundColor

表達 代表 Window 物件的變數。

傳回值

OLE_COLOR

註解

Visio 中的 OLE_COLOR 屬性的有效值可以是下列其中一項:

  • &H00 bbggrr, 其中 bb 是介於 0 和 0xFF (255) 之間的藍色值、 匯總 綠色 值,以及 紅色值。

  • &H800000 xx ,其中 xx 是有效的 GetSysColor 索 引。

如需 GetSysColor 函式的詳細資訊,請在 MSDN 上的 Microsoft Platform SDK 中搜尋 “ GetSysColor ”。

OLE_COLOR數據類型用於傳回色彩的屬性。 當屬性宣告為OLE_COLOR時,Visual Basic 編輯器中的 屬性視窗 會顯示色彩選擇器對話方塊,可讓使用者以可視化方式選取屬性的色彩,而不必記住對等數值。

此外,您也可以使用下列 OLE_COLOR 的 Microsoft Visual Basic for Applications (VBA) 色彩常數。

常數 描述
vbBlack 0x0 黑色
vbRed 0xFF 紅色
vbGreen 0xFF00 綠色
vbYellow 0xFFFF 黃色
vbBlue 0xFF0000 藍色
vbMagenta 0xFF00FF 洋紅色
vbCyan 0xFFFF00 青色
vbWhite 0xFFFFFF 白色

對於繪圖視窗、列印預覽視窗或全螢幕檢視視窗,將視窗的 BackgroundColor 屬性設定為預設 (-1 以外的值) 覆寫該視窗集的 ApplicationSettings.DrawingBackgroundColorApplicationSettings.PrintPreviewBackgroundColorApplicationSettings.FullScreenBackgroundColor 設定。 若要能夠針對同一組視窗重設這些屬性,您必須將 BackgroundColor 重設為其預設值 -1。 如果開啟多個繪圖,則為一組窗口設定 BackgroundColor 不會影響其他開啟視窗集的設定。

不過,對於 ShapeSheet 視窗,將視窗的 BackgroundColor 屬性設定為預設值以外的值會變更 ShapeSheet 視窗的背景色彩,但不會影響任何其他窗口設定。

範例

下列 VBA 宏示範如何使用 BackgroundColor 屬性來取得和設定目前的繪圖視窗背景色彩。 它也會示範如何從 Visio Application 物件取得 ApplicationSettings 物件,並示範 BackgroundColor 屬性與 ApplicationSettings.DrawingBackgroundColor 屬性之間的關聯性。 本範例假設 Visio 中已開啟使用中的繪圖視窗,而且一開始所有背景色彩屬性都會設定為其預設值。

Public Sub BackgroundColor_Example() 
 
 Dim vsoApplicationSettings As Visio.ApplicationSettings 
 Set vsoApplicationSettings = Visio.Application.Settings 
 
 'Get the current application background color. 
 Debug.Print vsoApplicationSettings.DrawingBackgroundColor 
 
 'Get the active window background color. 
 Debug.Print ActiveWindow.BackgroundColor 
 
 'Change the application background color. 
 'This also changes the active window color as 
 'well as the setting in the Color Settings dialog box. 
 vsoApplicationSettings.DrawingBackgroundColor = vbRed 
 
 'Change the active window background color. 
 ActiveWindow.BackgroundColor = vbMagenta 
 
 'Change the application background color again. 
 'This time, there is no change in the current 
 'window color, but the dialog box setting changes. 
 vsoApplicationSettings.DrawingBackgroundColor = vbYellow 
 
 'Reset Window.BackgroundColor to its default value. 
 ActiveWindow.BackgroundColor = -1 
 
 'Change the application background color again. 
 'Now both the active window color 
 'and the dialog box setting change. 
 vsoApplicationSettings.DrawingBackgroundColor = vbBlue 
 
End Sub

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應