- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
2#
發表於 2012-8-25 15:57
| 只看該作者
本帖最後由 GBKEE 於 2012-8-25 15:59 編輯
回復 1# roy1221
試試看- Option Explicit
- Dim Left_Msg As Boolean '表單私用變數
- Private Sub CommandButton1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
- 'CommandButton1 按下按鈕 的觸發事件程序
- Left_Msg = True
- Sub_Left
- End Sub
- Private Sub CommandButton1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
- 'CommandButton1 離開按鈕 的觸發事件程序
- Left_Msg = False 'Left_Msg = False 停止迴圈執行下去
- End Sub
- Private Sub Sub_Left() 'Left 是vba內建關鍵字,勿為變數,程序名稱
- '按下按鈕 要執行的程序
- Dim Shift As Integer
- Shift = Range("A7").Value
- ActiveSheet.Shapes("Group 2").Select
- Do While Left_Msg 'Left_Msg = True 迴圈執行下去
- DoEvents
- Application.StatusBar = Time '狀態列中顯示時間 說明程序在執行中
- Selection.ShapeRange.IncrementLeft -Shift * 75
- Loop
- ActiveCell.Activate
- End Sub
複製代碼 |
|