0
votes

I'm new to VBA and I've been asked to fix this code but I don't know what all the commas are for right after the open "{filename}". Can someone explain? Thanks!

Sub Fixed_Width_Test()
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.OpenText _
    `enter code here`"C:\Users\gcosta1\Desktop\BDTF\DAILY_ACTIVATION_TXN_CA_071113.txt", , , xlFixedWidth, , , , , , , , , Array(Array(0, 1), Array(2, 1), Array(27, 1), Array(77, 1), Array(92, 1), Array(108, 1), Array(128, 1), Array(153, 1), Array(178, 1), Array(203, 1), Array(211, 1), Array(217, 1), Array(249, 1), Array(179, 1), Array(287, 1), Array(293, 1), Array(301, 1), Array(317, 1), Array(334, 1), Array(337, 1), Array(353, 1), Array(383, 1), Array(386, 1), Array(392, 1), Array(393, 1), Array(410, 1), Array(421, 1))
End Sub
1

1 Answers

0
votes

Open text is a method in VBA which takes arguments like below

OpenText(FileName, Origin, StartRow, DataType, TextQualifier, ConsecutiveDelimiter, Tab, Semicolon, Comma, Space, Other, OtherChar, FieldInfo, TextVisualLayout, DecimalSeparator, ThousandsSeparator, TrailingMinusNumbers, Local)

In your code the first argument passed to this method is filename, then ,,, represents that no argument has been passed for origin,startrow and so on and so forth.

More details / source: http://msdn.microsoft.com/en-us/library/office/aa195814(v=office.11).aspx