现在我想实现这样的功能,在SE Client上用VBA读取当前主机名,根据主机名加载对应参数表,并且每隔几秒钟对变量进行赋值。
具体代码如下:
Private Sub ParaSwitch()
Dim Filename As String
Dim Data As String
Dim Com As String
Dim strParamFileName As String
Dim strCommand As String
Dim i As Integer
Dim omyElement As Element
Dim omyComputer As Element
Dim counter As Integer
i = 0
Com = Environ("computername")
Filename = "C:\Temp\startup\ClientMapping.txt"
Open Filename For Input Access Read As #1
Do While Not EOF(1)
Line Input #1, Data
If Len(Data) <> 0 Then
If InStr(Data, Com) > 0 Then
strParamFileName = "TagWriteAlarm_0" & i
strCommand = "Display header /P" & strParamFileName
ExecuteCommand (strCommand)
End If
i = i + 1
End If
Loop
Close #1-------红色代码为根据主机名加载对应参数表
While True
For counter = 0 To 9
Set omyElement = Me.FindElement("NumericInput" & CStr(counter))
omyElement.Value = Int((100 * Rnd) + 1)
Next
Set omyComputer = Me.FindElement("StringInput1")
omyComputer.Value = Environ("computername")
Pause 1
Application.ExecuteCommand "downloadall"
Pause 2
Wend---------绿色部分为加载好参数表后,向参数表中引用的变量进行赋值。这个部分需要每间隔一段时间赋值一次,所以要用循环。
End Sub
但现在的问题是,只要ExecuteCommand (strCommand)这条语句被执行,也就是加载参数表指令。后面绿色部分的代码就无法运行,起码看现象是这样的,变量没有被赋值。
求各位大神帮忙看看,如何解决!