emorris1000
Registered User.
- Local time
- Today, 12:54
- Joined
- Feb 22, 2011
- Messages
- 125
Been working on some stuff that requires me to open a tab delimited text file in excel. I have the Excel scripting library referenced, the basic codes goes as follows (with a couple of irrelevant deletions).
That last line throws a compile error. I lifted most of this code directly out of an Excel VBA script I wrote a while ago. I referenced the Excel scripting library and I believe the way I have modified it should run here...
Anyways, anyone have any ideas why that's not working right?
Code:
Dim StrFilePathB As String
Dim fname As String
Dim rs As Recordset
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
fname = "~~~~~filename~~~~"
StrFilePathB = "~~~file location~~~"
Set xlApp = GetObject(, "Excel.Application")
If xlApp Is Nothing Then 'No instance of Excel is available
Set xlApp = New Excel.Application
End If
Set xlBook = xlApp.Workbooks.OpenText(filename:= "" & StrFilePathB & fname & "", StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1), TrailingMinusNumbers:=True, Local:=True)
......
That last line throws a compile error. I lifted most of this code directly out of an Excel VBA script I wrote a while ago. I referenced the Excel scripting library and I believe the way I have modified it should run here...
Anyways, anyone have any ideas why that's not working right?