In =RTD(ProgID,Server,String1,[String2],..),为String2, String



是否有任何方法将myStringArray传递给RTD函数?

Data = "A,B,C"
Dim myStringArray() As String     `
myStringArray = Split(Data, ",")`
Application.WorksheetFunction.RTD("rtd.server.1", "", "" + URL+ "", "User", "Query", myStringArray)

期望RTD服务器接收到"url"、"用户"、"查询"、"a"、"b"、"c";作为论据。我试了上面的方法,但是没有成功。

由于WorksheetFunction.RTD()方法(https://learn.microsoft.com/en-us/office/vba/api/excel.worksheetfunction.rtd)签名(即:它接受多少个参数和哪种类型),您可以使用"预处理器",如下所示:

Sub PreProcessingForRTD(progID As Variant, server As Variant, topic1 As Variant, ParamArray otherTopics() As Variant)
Dim topics(1 To 28) As Variant

topics(1) = topic1

Dim iTopic As Long
iTopic = 1
Dim arg As Variant
For Each arg In otherTopics
Select Case True
Case IsArray(arg)
Dim argArg As Variant
For Each argArg In arg
iTopic = iTopic + 1
topics(iTopic) = argArg
Next
Case Else
iTopic = iTopic + 1
topics(iTopic) = arg

End Select
Next
'change 'Debug.Print' to whatever real usage you are making of 'Application.WorksheetFunction.RTD()'
Debug.Print Application.WorksheetFunction.RTD(progID, server, topics(1), _
topics(2), topics(3), topics(4), topics(5), topics(6), topics(7), topics(8), topics(9), topics(10), topics(11), topics(12), topics(13), topics(14), topics(15), topics(16), topics(17), topics(18), topics(19), topics(20), topics(21), topics(22), topics(23), topics(24), topics(25), topics(26), topics(27), topics(28))

End Sub

您将在您的"main">

Dim DATA As String
DATA = "A,B,C"
Dim myStringArray() As String
myStringArray = Split(DATA, ",")
Dim url As String
url = "myURL"

PreProcessingForRTD "rtd.server.1", "", "" + url + "", "User", "Query", myStringArray

相关内容

  • 没有找到相关文章

最新更新