excel을 VBA로 사용하여 지정된 형식의 TXT 파일 생성하기

3581 단어 Excel
Sub  TXT ()



    Dim s As String



    Dim FullName As String, rng As Range



    Application.ScreenUpdating = False



     FullName = (ActiveSheet.Name & ".txt")   ' TXT 



 '   FullName = Replace(ThisWorkbook.FullName, ".xls", ".txt")  ' TXT 



 '   FullName = Replace(ThisWorkbook.FullName, ".xls", ActiveSheet.Name & ".txt")  ' & TXT 



    Open FullName For Output As #1    '



    ' ,fullname 



    For Each rng In Range("a1").CurrentRegion



        s = s & IIf(s = "", "", "|") & rng.Value



        If rng.Column = Range("a1").CurrentRegion.Columns.Count Then



            Print #1, s & "|"   ' 



            s = ""



        End If



    Next



    Close #1    ' 



    Application.ScreenUpdating = True



    MsgBox " "



End Sub

좋은 웹페이지 즐겨찾기