Har du set hvor smart det kan være?

Microsoft Office, Word skabeloner, Excel regnearkSmart Office Word skabelon system

SmartOffice - SeperatedFile

Dan en separeret fil efter eget ønske – f.eks. en komma- eller kolonsepareret fil



Eksempel 1

Public Sub MyOwnSeperatedFile()
' Flemming Vadet, August 2002, fv@smartoffice.dk
    Const sSEPERATOR As String = ","
    Const sFILE_NAME As String = "C:\test.txt"
    Dim rCell As Range
    Dim rRow As Range
    Dim rCurReg As Range
    Dim sLine As String
    Dim iFile As Integer
    ' Find a free file number
    iFile = FreeFile
    ' Remove column headers in the first row
    Set rCurReg = ActiveSheet.Range("A1").CurrentRegion
    Set rCurReg = rCurReg.Offset(1, 0).Resize(rCurReg.Rows.Count - 1, _
        rCurReg.Columns.Count)
    ' Open the file
    Open sFILE_NAME For Output As #iFile
        For Each rRow In rCurReg.Rows
            For Each rCell In rRow.Cells
                ' Make each line
                sLine = sLine & CStr(rCell.Value) & sSEPERATOR
            Next rCell
            ' Write the line into the file
            Print #iFile, Left$(sLine, Len(sLine) - 1)
            sLine = ""
        Next rRow
    ' Close the file
    Close #iFile
    ' Clean up
    Set rCell = Nothing
    Set rRow = Nothing
    Set rCurReg = Nothing
End Sub


Download eksempel

   

Smart Office Freeware Smart Data Management
Compare 2 Columns
Excel Super- Subscript
Teachers Excel Tools
         
Smart Office - Word og Excel specialist