Textfiles, Excel

Writing to a textfile

Dim intFile As Integer
intFile = FreeFile
Open "C:\Test.txt" For Output As #intFile
Print #intFile, "first line of text"
Print #intFile, " second line of text"
Print #intFile, "" 'blank line
Print #intFile, "some more text!"
Close #intFile

Reading from a textfile

Dim intFile As Integer
intFile = FreeFile
Open "C:\Test.txt" For Input As #intFile
...
Close #intFile

Export to Excel

Reference: Microsoft Excel 11.0 Object Library (not selected underneath imported namespaces, if so no need to include the 'Imports'-line)
Imports Excel = Microsoft.Office.Interop.Excel
Dim xlsApp As New Excel.Application
Dim xlsWB As Excel.Workbook
Dim xlsSheet As Excel.Worksheet
Dim xlsRange As Excel.Range
xlsWB = xlsApp.Workbooks.Open(adresfile)  'xlsWB = xlsApp.Workbooks.Add(adresfile)
xlsSheet = DirectCast(xlsWB.Worksheets(1), Excel.Worksheet)
xlsRange = DirectCast(xlsSheet.Cells(intTeller, 1), Excel.Range)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License