Friday, November 25, 2005

第十六章 Office小幫手與汽球文字說明

第十六章 Office小幫手與汽球文字說明
16-01 顯示/隱藏Office小幫手

應用範例
Sub 顯示或隱藏Office小幫手()
MsgBox “切換Office小幫手顯示/隱藏的狀態”
Assistant.Visible = Not (Assistant.Visible)
End Sub

16-02 移動Office小幫手

應用範例
Sub 移動Office小幫手()
x = 200
y = 250
MsgBox “將Office小幫手移到螢幕(” & x & “,” & y & “)的位置”
Assistant.Move x, y
End Sub

16-03 變更Office小幫手的動畫效果

應用範例
Sub 設定動畫效果()
MsgBox “依序顯示Office小幫手的動畫效果類型”
anime = Application.Assistant.Animation
For i = 100 To 116
Application.Assistant.Animation = i
MsgBox “Office小幫手目前的動畫效果常數值:” & i
Next i
MsgBox “回復原來的動畫效果”
Application.Assistant.Animation = anime
End Sub

16-04 Office小幫手的汽球說明文字

應用範例
Sub 汽球中的提示訊息()
MsgBox “建立汽球,並在汽球中顯示提示訊息”
With Assistant.NewBalloon
.Icon = msoIconTip
.Heading = “小計的使用方法”
.Labels(1).Text = “首先,請點選「資料」”
.Labels(2).Text = “其次,請點選「小計」”
.Button = msoButtonSetOK
.Show
End With
Application.Assistant.Visible = False
End Sub

16-05 在汽球中建立標籤

應用範例
Sub 汽球與標籤的應用()
MsgBox “為Office小幫手建立內含標籤選項的汽球”
With Application.Assistant.NewBalloon
.Heading = “◆資料排序◆”
.Text = “請點選下列的項目:”
.Labels(1).Text = “依據姓名遞增排序”
.Labels(2).Text = “依據編號排序”
.Labels(3).Text = “取消”
.Button = msoButtonSetNone
sentaku = .Show
End With
Select Case sentaku
Case 1
Msgbox “依據姓名遞增排序”
hanni = “A2:C12”
kii = “B2”
ActiveSheet.Range(hanni).Select
retu = Range(kii).Value
Selection.Sort key1:=Range(kii), header:=xlYes, Order1:=xlAscending
Case 2
MsgBox “依據編號排序”
hanni = “A2:C12”
kii = “A2”
ActveSheet.Range(hanni).Select
retu = Range(kii).Value
Selection.Sort key1:=Range(kii), header:=xlYes, Order1:=xlAscending
Case 3
MsgBox “取消”
End Select
End Sub

16-06 在汽球中建立核取方塊

應用範例
Sub 汽球與核取方塊的應用()
MsgBox “為Office小幫手建立內含核取方塊的汽球”
With Assistant.NewBalloon
.Heading = “變更A2到C2儲存格範圍的格式”
.Text = “勾選欲執行的項目後,請按OK ”
.CheckBoxes(1).Text = “變更為粗體字”
.CheckBoxes(2).Text = “變更為斜體字”
.Button = msoButtonSetOK
.Show
If .CheckBoxes(1).Checked = True Then
Range(“A2:C2”).Font.Bold = True……1
Else
Range(“A2:C2”).Font.Bold = False……2
End If
If .CheckBoxes(2).Checked = True Then
Range(“A2:C2”).Font.Italic = True……3
Else
Range(“A2:C2”).Font.Italic = False……4
End If
End With
End Sub

0 Comments:

Post a Comment

<< Home