An Example Using Write # and Input # : FreeFile « File Path « VBA / Excel / Access / Word

VBA / Excel / Access / Word
1. Access
2. Application
3. Data Type
4. Data Type Functions
5. Date Functions
6. Excel
7. File Path
8. Forms
9. Language Basics
10. Math Functions
11. Outlook
12. PowerPoint
13. String Functions
14. Windows API
15. Word
16. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
VBA / Excel / Access / Word » File Path » FreeFile 
An Example Using Write # and Input #
 

Sub TestWriteInput()
    Dim lOutputFile As Long
    Dim rg As range
    Set rg = ThisWorkbook.Worksheets(1).range("a1")
    lOutputFile = FreeFile
    Open "C:\Write Example.txt" For Output As #lOutputFile
    Do Until IsEmpty(rg)
        Write #lOutputFile, rg.value, _
            rg.Offset(01).value, _
            rg.Offset(02).value, _
            rg.Offset(03).value, _
            rg.Offset(04).value, _
            rg.Offset(05).value, _
            rg.Offset(06).value, _
            rg.Offset(07).value
        Set rg = rg.Offset(10)
    Loop

    Set rg = Nothing
    Close lOutputFile

    Dim lInputFile As Long
    Dim v1, v2, v3, v4
    Dim v5, v6, v7, v8

    Set rg = ThisWorkbook.Worksheets(2).range("a1")
    rg.CurrentRegion.ClearContents
    lInputFile = FreeFile
    Open "C:\Write Example.txt" For Input As lInputFile
    Do Until EOF(lInputFile)
        Input #lInputFile, v1, v2, v3, v4, v5, v6, v7, v8
        rg.value = v1
        rg.Offset(01).value = v2
        rg.Offset(02).value = v3
        rg.Offset(03).value = v4
        rg.Offset(04).value = v5
        rg.Offset(05).value = v6
        rg.Offset(06).value = v7
        rg.Offset(07).value = v8
        Set rg = rg.Offset(10)
    Loop

    Set rg = Nothing
    Close lInputFile
End Sub

 
Related examples in the same category
1. Examples of the VBA Open Statement
2. Text Files and File Dialog
3. Writing to Text Files Using Print
4. Reading Data Strings
5. Flexible Separators and Delimiters
6. uses the delimiter characters to decide the data type of each item and treat it appropriately:
7. Handling Files with Low-Level File Handling
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.