- 6
- 0
- 约1.08万字
- 约 10页
- 2018-03-09 发布于河南
- 举报
如何插入iFIX动态数据到Excel工作
写IFIX实时数据到Excel
2007-02-28 11:22
DescriptionInserting?FIX?Dynamics?data?into?an?Excel?worksheet.
Resolution?The?following?procedure?will?enable?you?to?insert?FIX?Dynamics?data?into?an?Excel?worksheet:
//?Declare?necessary?API?routines:Private?Declare?Function?FindWindow?Lib?user32?Alias?_FindWindowA?(ByVal?lpClassName?As?String,?_ByVal?lpWindowName?As?Long)?As?Long
Private?Declare?Function?SendMessage?Lib?user32?Alias?_SendMessageA?(ByVal?hwnd?As?Long,?_ByVal?wMsg?As?Long,?_ByVal?wParam?As?Long,?_lParam?As?Any)?As?LongSub?DetectExcel()//?Procedure?dectects?a?running?Excel?and?registers?it.Const?WM_USER?=?1024Dim?hwnd?As?Long//?If?Excel?is?running?this?API?call?returns?its?handle.hwnd?=?FindWindow(XLMAIN,?0)If?hwnd?=?0?Then?//?0?means?Excel?not?running.Exit?SubElse//?Excel?is?running?so?use?the?SendMessage?API//?function?to?enter?it?in?the?Running?Object?Table.SendMessage?hwnd,?WM_USER?+?18,?0,?0End?IfEnd?Sub
Private?Sub?CommandButton2_Click()
Dim?msexcel?As?Excel.ApplicationSet?msexcel?=?CreateObject(Excel.Application)
With?msexcel.Visible?=?True.Workbooks.Open?d:fix32Test1.xls,?,?FalseEnd?With
End?Sub
Private?Sub?CommandButton3_Click()Dim?MyXL?As?Object?//?Variable?to?hold?reference?to?Microsoft?Excel.Dim?ExcelWasNotRunning?As?Boolean?//?Flag?for?final?release.
//?Test?to?see?if?there?is?a?copy?of?Microsoft?Excel?already?running.On?Error?Resume?Next?//?Defer?error?trapping.
//?Getobject?function?called?without?the?first?argument?returns?a//?reference?to?an?instance?of?the?application.?If?the?application?isn//t//?running,?an?error?occurs.?Note?the?comma?used?as?the?first?argument//?placeholder.Set?MyXL?=?GetObject(,?Excel.Application)If?Err.Number??0?Then?ExcelWasNotRunning?=?TrueErr.Clear?//?Clear?Err?object?in?case?error?occurred.
//?Check?for?Excel.?If?Excel?is?running,//?enter?it?into?the?Running?Object?table.DetectExcel
//Set?the?object?variable?to?reference?the?file?you?want?to?see.Set?MyXL?=?GetObject(d:fix32?est1.XLS)
/
原创力文档

文档评论(0)