-
Solved: Defining .csv-file as workbook
I'm working with a .csv-file which I open like this:
[vba]Workbooks.OpenText Filename:="C:\abc.csv", Origin:=xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlNone, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=True, Comma _ 'etc
[/vba]
How do I define the .csv-file as a workbook?
[vba]Dim MyFile As Workbook
MyFile = 'what do I put here?[/vba]
-
[VBA]Sub OpenCsv()
Dim MyFile As Workbook
Set MyFile = Workbooks.Open(Filename:="C:\abc.csv")
MsgBox MyFile.Sheets.Count
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
Since the .csv-file is already open, I used
[VBA]Dim MyFile As WorkBook
Set MyFile = Workbooks("abc.csv")[/VBA]
And it worked fine.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules