SmallCraig
MIS
This is a question I've considered for some time, but the need hasn't been so pressing until now.
In Excel, the "opentext" method accepts an array of "fieldinfo", which tells the open method how to treat each column of data imported. I have the potential need to make that array variable in nature, and pass to the Excel object the number of columns I'm expecting it to process.
I've tried setting up a string of "Array(a,1),Array(b,1)...", then placing the string in the statement:
This code falls over on the "opentext".
Can this ever work? Does it make a difference that I'm calling this from a VB program (just imagine that the correct object details precede the method names)?
I'd appreciate any input on this issue.
Thanks loads,
SmallCraig
In Excel, the "opentext" method accepts an array of "fieldinfo", which tells the open method how to treat each column of data imported. I have the potential need to make that array variable in nature, and pass to the Excel object the number of columns I'm expecting it to process.
I've tried setting up a string of "Array(a,1),Array(b,1)...", then placing the string in the statement:
Code:
strFieldArray = "Array(1, 1),Array(2, 1)"
For intLoop = 1 To pWeeks
strFieldArray = strFieldArray & ",Array(" & CStr (intLoop + 2) & ",2)"
Next
Workbooks.OpenText _
Filename:=pInputFile, _
Origin:=xlWindows, _
StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote,
ConsecutiveDelimiter:=False, _
Tab:=False, Semicolon:= _
False, Comma:=False, Space:=False,
Other:=True, OtherChar:="#", _
FieldInfo:=Array(strFieldArray)
This code falls over on the "opentext".
Can this ever work? Does it make a difference that I'm calling this from a VB program (just imagine that the correct object details precede the method names)?
I'd appreciate any input on this issue.
Thanks loads,
SmallCraig