Creating a Complex Array with Defined Structure (SOAP)

frolicols

New Member
Joined
May 11, 2011
Messages
15
I am trying to create an array with defined elements. I have a class file called struct_message:

Code:
Public originator As String
Public recipient As String
Public body As String
Public messagetype As String
Public validityperiod As Long

I then wish to create an array object an assign the various elements to each index. Is this correct? My current code is:

Code:
Sub BuildArray()

Dim aMessages() As struct_message

For i = 1 to 5

aMessages(i).originator = "Test"
aMessages(i).recipient = "Someone's Name"  'This will be changed to cycle through the recipients
aMessages(i).body = "The Message" 'This will be changed to cycle through individual messages
aMessages(i).messagetype = "Text"
aMessages(i).validityperiod = 0

Next i

End Sub

When I run the code I'm getting a Subscript Out of Range error. This is for use to upload using a SOAP service. Any ideas why I can't assign the indexed elements?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
You haven't declared the size of your array, hence you cannot assign anything to it.
 
Upvote 0
OK I've managed to tidy up my code and it now works in that it creates a variant array with elements defined by my struct_message class file.

After all this, the problem I've now found out is the SOAP Toolkit code does not like complex arrays! Apparently I need to turn my complex array into a simple one using the MSXML Parser.

I've found an example here:

http://msdn.microsoft.com/en-us/library/aa140267(v=office.10).aspx#odc_wsrtct_parsing

This example takes a simple array input and parses a complex array as an output. I need it the other way round (complex array input, simple 1d array output).

How do I pass information into IXMLDOMNodeList and IXMLDOMNode?
 
Upvote 0

Forum statistics

Threads
1,224,561
Messages
6,179,522
Members
452,923
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top