shubhraj
shubhraj

Reputation: 387

How to fetch the data member of Object Variable in excel macro?

I have this macro which fetches using Rfc connection. I am able to fetch the data but I require to split the data as per requirement. The screen shot below , The first Line shows The table from which I am fetching the data.

enter image description here

I have declared RFC_TAB as Object and I am fetching data into it.

 Dim RFC_TAB As Object

The Below screenshot shows the data.

enter image description here

I am moving the data into str defined as Variant i.e

 Dim str As Variant

enter image description here

But when I try to access specific entry in it. i.e

 Dim str1 As Variant
 str1 = str.str(1).str(1 , 2)

It gives the following error

enter image description here

How can I get specific entries from

str

so that I can split it to display in excel cells . I am new to macro programming.

Upvotes: 3

Views: 898

Answers (1)

JustinJDavies
JustinJDavies

Reputation: 2693

str appears to be a 2d array of type Variant(). You have to address the correct index, try:

Dim str1 As Variant
str1 = str(1 , 2)

Better, try:

Dim str1 As String
str1 = str(1 , 2)

For extreme safety, try:

Dim str1 As String
str1 = CStr(str(1 , 2))

Given you know the type of the object you are addressing

Upvotes: 2

Related Questions