Dim xl As Excel.Application: Set xl = CreateObject("Excel.Application")
Dim wbs As Excel.Workbooks
Dim wb As Excel.Workbook
xl.ScreenUpdating = False
'DGSF001
Set wb = Workbooks.OpenText(FileName:=cSalesForceDownloadLocation & sf1 & MMDDYYFormat & ".TXT", Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 2), Array(3, 1), Array(4, 2), Array(5, 2), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 2), Array(10, 2), Array(11, 1), Array(12, 2), _
Array(13, 1), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 2), Array(22, 1), _
Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1), Array(27, 1), Array(28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1), _
Array(33, 1), Array(34, 1), Array(35, 1), Array(36, 1), Array(37, 1), Array(38, 1), Array(39, 1), Array(40, 1), Array(41, 1), Array(42, 1), _
Array(43, 1), Array(44, 1), Array(45, 1), Array(46, 1), Array(47, 1), Array(48, 2), Array(49, 2)), TrailingMinusNumbers:=True)
wb.SaveAs FileName:=cSalesforcePath & YYYYMMDDFormat & "\" & cAProducer & sf1 & MMDDYYFormat & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
wb.Close
It looks correct but I keep receiving a compile error on the Worksbooks.OpenText line that says "Expected Function or Variable." That works in Excel. I even tried Excel.Workbooks.OpenText and xl.Workbooks.OpenText. I already set a Reference to the Excel Object model in the References section. What am I missing here?
Bookmarks