程序运行结果:D盘指定excel文件"D:\TradeExcel.xlsx"能够打开,单元格A1的值赋为123
问题是:为什么在MarketData_ReportNotify触发之后,单元格A2没有显示最新价格
请问是什么原因,请高手指点,谢谢~~
-----------------------------
public ExcelApp
Sub APPLICATION_VBAStart()
Call MarketData.RegReportNotify("ZS05","CB")
Set ExcelApp = GetObject("D:\TradeExcel.xlsx")
ExcelApp.Parent.Windows("TradeExcel.xlsx").Activate
ExcelApp.Application.Visible = True
ExcelApp.Application.Workbooks(1).Worksheets(1).Cells(1,1).Value=123
End Sub
Sub MarketData_ReportNotify(ReportData)
dim NewPrice
NewPrice = ReportData.NewPrice
ExcelApp.Application.Workbooks(1).Worksheets(1).Cells(2,1).Value = NewPrice
End Sub
on error resume next
Set ExcelApp = GetObject(, "Excel.Application") '
If Err.Number <> 0 Then
Set ExcelApp = CreateObject("Excel.Application")
End if
'将对象变量设为对要看的文件的引用。
Set ExcelApp = GetObject("D:\TradeExcel.xlsx")
代码中打开Excel文件的代码需要做修改,有行情的时候才能测试