已经毕业快一年了,今天一个师弟问我winwedge软件如何记录satorius天平数据。 经过一翻折腾,终于解决。为防止自己忘记,也方便后续同学的学习。记录操作过程。
step1:下载winwedge软件并安装
step2:打开Excel,进入开发者模式(Alt+F11),新建立一个模块。
step3:新建立一个模块,双击进入模块,输入如下代码
Sub GetSingleField()
'Dimension all variables
Dim R As Long, Chan As Long, vDat As Variant, sDat As String
' Find the next empty row in Column A
R = ThisWorkbook.Sheets("Sheet1").Cells(65000, 1).End(xlUp).Row + 1
'Establish DDE link to WinWedge on COM1
Chan = DDEInitiate("WinWedge", "COM1")
' The following 3 lines of code can be duplicated to collect
' additional fields of data into different columns.
vDat = DDERequest(Chan, "Field(1)") ' Request the data from Field(1) in WinWedge
sDat = vDat(1) ' Convert the data into a string
ThisWorkbook.Sheets("Sheet1").Cells(R, 1).Value = sDat ' Put data in cell at Row = R, Column = 1
DDETerminate Chan ' Terminate the DDE link
' You can also insert a date/time stamp in Column B by uncommenting the following line.
' ThisWorkbook.Sheets("Sheet1").Cells(R, 2).Value = Now
End Sub
step4: 配置winwedge软件的端口、命令等,方便与电子天平通信(这些见说明书)。
[port菜单下进入,设置端口信息]
然后进入Model的DDEserver
输入如下内容
step5: 然后点击winwedge菜单activate下的test mode或normal mode就可以把读取的天台数据写入Excel了
ref:
[1]https://www.taltech.com/support/entry/collecting_a_single_field_of_data_into_excel
[2]https://www.taltech.com/sartoriuswedge/support