0

is there any way to pass myStringArray to the RTD function?

Data = "A,B,C"
Dim myStringArray() As String     `
myStringArray = Split(Data, ",")`

Application.WorksheetFunction.RTD("rtd.server.1", "", "" + URL+ "", "User", "Query", myStringArray)

Expecting the RTD server to receive "URL", "User", "Query", "A", "B", "C" as the arguments. I tried the above but it did not work.

user3598756
  • 28,893
  • 4
  • 18
  • 28

1 Answers1

0

Since WorksheetFunction.RTD() method (https://learn.microsoft.com/en-us/office/vba/api/excel.worksheetfunction.rtd) signature (i.e.: how many parameters it is accepting and of which type), you could use a "Preprocessor", like the following:

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

That you will use in your "main" sub as follows:

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
user3598756
  • 28,893
  • 4
  • 18
  • 28