PDA

View Full Version : Solved: Defining .csv-file as workbook



ulfal029
12-04-2008, 02:28 AM
I'm working with a .csv-file which I open like this:

Workbooks.OpenText Filename:="C:\abc.csv", Origin:=xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlNone, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=True, Comma _ 'etc


How do I define the .csv-file as a workbook?

Dim MyFile As Workbook
MyFile = 'what do I put here?

mdmackillop
12-04-2008, 06:52 AM
Sub OpenCsv()
Dim MyFile As Workbook
Set MyFile = Workbooks.Open(Filename:="C:\abc.csv")
MsgBox MyFile.Sheets.Count
End Sub

ulfal029
12-04-2008, 07:21 AM
Since the .csv-file is already open, I used
Dim MyFile As WorkBook
Set MyFile = Workbooks("abc.csv")
And it worked fine.