0

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
4

1 回答 1

0

开放文本是 VBA 中的一种方法,它采用如下参数

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

在您的代码中,传递给此方法的第一个参数是文件名,然后 ,,, 表示没有为 origin、startrow 等传递任何参数,依此类推。

更多细节/来源: http: //msdn.microsoft.com/en-us/library/office/aa195814 (v=office.11​​).aspx

于 2013-08-13T22:37:39.823 回答