I want to write a text file that contains all the data from within an object. I know how to create and open a text file using vba, also how to write from a range or string going through every line but I have not found a solution for doing the same with an object. Any help would be appreciated. The object in question is genereated by parsing a .json file into an object in vba and then selecting the necessary objects withing.
Public Sub exportobejct(obj)
dim path as string
dim filename as string
dim filenumber as string
path = "C:\Mypath\"
filename = "myfilename"
filenumber = Freefile
Open filepath & filename for output as filenumber
'Here would be the code to write into the textfile, which I failed
'What I tried:
For r in obj.rows.cells.count-1
for c in obj.columns.cells.count-1
print filenumber, obj.cells(r,c)
'or
print filenumber, obj.cells(1).offset(r,c).value
next c
next r
'sth else I tried:
Print filenumber, obj
'or
for each cc in obj.rows
write filenumber, cc
next cc
Close filenumber
End sub
Ive seen there is also an option creating files using FSO see Link: https://stackoverflow.com/questions/11503174/how-to-create-and-write-to-a-txt-file-using-vba
I still dont know how to write from an object however.
Some additional information: The object that I want to write from may contain several more objects > within, if that poses any issues.