A B C D
1 代碼 商品 成交 昨收
2 2330 台積電 115.5 114.5
3
4 1
我打在this workbook
Private Declare Function PlaceOrderVB Lib "TC_Excel_Addin.xll" (ByVal OrderInfo As String) As String
Option Explicit
------------------------------------------------------------------------------------
Private Sub Worksheet_calculate()
Dim tmpResult As String
Dim OrderInfo_1 As String
tmpResult = ""
變成這樣??
Private Declare Function PlaceOrderVB Lib "TC_Excel_Addin.xll" (ByVal OrderInfo As String) As String
Option Explicit
------------------------------------------------------------------------------------
Private Sub Worksheet_calculate()
Dim tmpResult As String
Dim OrderInfo_1 As String
tmpResult = ""
Private Declare Function PlaceOrderVB Lib "TC_Excel_Addin.xll" (ByVal OrderInfo As String) As String
Option Explicit
------------------------------------------------------------------------------------
Private Sub Worksheet_calculate()
Dim tmpResult As String
Dim OrderInfo_1 As String
tmpResult = ""
<工作表事件區.程式碼>
Private Declare Function PlaceOrderVB Lib "TC_Excel_Addin.xll" (ByVal OrderInfo As String) As String
Option Explicit
Private Sub Worksheet_Calculate()
Dim tmpResult As String
Dim OrderInfo_1 As String
If Date Mod 7 - 1 > 5 Then Exit Sub '今天為〔周六.周日〕非交易日.跳出
If Time < TimeValue("08:00:00") Then Exit Sub '未到開盤.跳出
If Time > TimeValue("13:45:00") Then Exit Sub '已過收盤.跳出
If [D5] = "已送單" And [D6] = Date Then Exit Sub '今天已有送單記錄.跳出
If IsError([D4]) Then Exit Sub 'DDE未正確連結,或公式有誤.跳出
If Val([D4]) < 0 Then Exit Sub '未達目標價.跳出
On Error GoTo 901 '程式執行錯誤時,強制跳至901行,以回復事件觸發,並跳出
'-------------------------------------------
Application.EnableEvents = False
OrderInfo_1 = "" ' 裡面是個資, 下單的設定
tmpResult = PlaceOrderVB(OrderInfo_1)
PlaceOrderVB (OrderInfo_1)
[D5] = "已送單" '送單訊息
[D6] = Date '送單日期
[D7] = Time '送單時間
901: Application.EnableEvents = True
End Sub