我是用的专业版2016,VB脚本在我电脑上面无法运行并报警“无效的过程调用或参数”,但是同样文件在别的电脑是可以正常运行,不知是否EXCEL哪里有什么设置,求解!
非常感谢!
VB代码
Public Sub GenDB20()
Dim sHeader As String
Dim sData As String
Dim wsElem As Worksheet
Dim wsDB As Worksheet
Dim i, iEnd, iEl As Integer
Dim iOrte, iBGLTX As Integer
Dim res As Variant
Set wsElem = Worksheets.Item("Elements")
Set wsDB = Worksheets.Item("DB20")
sHeader = wsDB.Cells(1, 1).Value
iEnd = 1000 + 3
sData = ""
For i = 4 To iEnd
If (wsElem.Cells(i, 2).Value < 1 Or wsElem.Cells(i, 2).Value > 1000) Then
res = MsgBox("Wrong value in column ""ST"" (A) row: " & i, vbCritical)
Exit Sub
End If
iEl = wsElem.Cells(i, 2).Value
iOrte = 0
iBGLTX = 0
If IsNumeric(wsElem.Cells(i, 3).Value) Then iOrte = CInt(wsElem.Cells(i, 3).Value)
If IsNumeric(wsElem.Cells(i, 5).Value) Then iBGLTX = CInt(wsElem.Cells(i, 5).Value)
sData = sData & "EL[" & iEl & "].ORTE := " & iOrte & ";" & vbLf
sData = sData & "EL[" & iEl & "].BGLTX := " & iBGLTX & ";" & vbLf
Next i
res = Application.GetSaveAsFilename(Filefilter:="S7 Source, *.awl")
If res <> False Then
Set TS = mFSO.CreateTextFile(res, True)
TS.Write (sHeader & vbLf & sData & "END_DATA_BLOCK") '在这里会无法执行
TS.Close
End If
End Sub