ES官方VBA接口说明已久未更新,本VBA接口简写可供读者参考。
'-----------------------------------------------------
'VBA简化代码by woylin 2014-9-28
'-----------------------------------------------------
'★提数★
Private Sub btn1_Click()
Application.COMAddIns("esclient10.connect").Object.execquery"提数1"
End Sub
'★回写★
Private Sub btn2_Click()
If Application.COMAddIns("esclient10.connect").Object.execupdate("回写1")Then MsgBox "OK"
End Sub
'★新建★
Private Sub btn4_Click()
Application.COMAddIns("esclient10.connect").Object.newreport"入库单"
End Sub
'注意第二参数用于控制关闭调用源表单,官方教程中未指出,加该参数易导致崩溃
Private Sub btn5_Click()
Application.COMAddIns("esclient10.connect").Object.newreport"出库单",1
End Sub
'以下为带传入参数的新建
Private Sub btn5_Click()
with Application.COMAddIns("esclient10.connect").Object
.addinitData 字段1,值1
.addinitData 字段2,值2
'......
.newreport"出库单"
End with
End Sub
'★弹出规范★
Private Sub btn1p_Click()
[i6].Select:Application.COMAddIns("esclient10.connect").Object.poptree "名字_树"
End Sub
'注意该接口可调用列表规范,官方教程中未指出
Private Sub btn2p_Click()
[d6].Select:Application.COMAddIns("esclient10.connect").Object.poptree "批次库存_列表"
End Sub
'★插入行★
Private Sub btn9_Click()
Application.COMAddIns("esclient10.connect").Object.InsertRow1, 6, 1
End Sub
'★保存★
Private Sub btnSave_Click()
Application.COMAddIns("esclient10.connect").Object.savecase, , 0
End Sub
'★存储过程★
Private Sub btn1n_Click()
Dim sErr$
If Application.COMAddIns("esclient10.connect").Object.ExecProc("存储过程名",sErr, "参数") Then MsgBox "已更新"
End Sub
'★存储过程(带结果集)★
Private Sub btn2n_Click()
Dim Rs As New ADODB.Recordset, sErr$
If Application.COMAddIns("esclient10.connect").Object.ExecQryProc("存储过程名",Rs, sErr, "参数") Then myGrid1.SetDatasource Rs
End Sub
PS:示例库见群文件EdenSolution_11th_final.zip