+ Reply to Thread
Results 1 to 3 of 3

Export to Text file.

Hybrid View

  1. #1
    Cactus
    Guest

    Export to Text file.

    Please help me.

    I writen this VBA code for export range to Text file.



    --------
    Option Explicit

    Private Sub ExportButton_Click()
    Dim fHand As Long, expCode As Variant

    fHand = FreeFile
    Open ExportName For Output As fHand

    Write #fHand, TextBox 'TextBox included text "[Example]"
    Write #fHand, "key_temp="

    For Each expCode In Range(CodeRef)
    Write #fHand, 1, expCode
    Next expCode

    Close fHand
    End Sub


    --------
    I want export content should like this

    [Example]
    key_temp=1,000690;1,000063;1,000022;1,000829;0,600001;0,600005;0,000001;1,39
    9001;


    --------
    But now is this.

    "[Example]"
    "key_temp="
    1,"000633"
    1,"000830"
    1,"000056"
    1,"000407"
    1,"000806"
    1,"000860"
    1,"000881"
    1,"000850"
    1,"000928"
    1,"000717"


    --------
    How to remove the quotation mark?
    how i export the ';' semicolon mark?


    Thanks a lot.



  2. #2
    Dave Peterson
    Guest

    Re: Export to Text file.

    Maybe this'll help:

    Option Explicit
    Private Sub ExportButton_Click()
    Dim fHand As Long
    Dim expCode As Range
    Dim ExportName As String
    Dim myStr As String

    ExportName = "C:\my documents\excel\test.out"

    fHand = FreeFile
    Open ExportName For Output As fHand

    Print #fHand, "[Example]" 'change this back
    Print #fHand, "key_temp=";

    myStr = ""
    For Each expCode In Range("CodeRef").Cells
    myStr = myStr & ";1," & Format(expCode.Value, "000000")
    Next expCode

    myStr = myStr & ";"
    myStr = Mid(myStr, 2)
    Print #fHand, myStr

    Close fHand
    End Sub


    Cactus wrote:
    >
    > Please help me.
    >
    > I writen this VBA code for export range to Text file.
    >
    > --------
    > Option Explicit
    >
    > Private Sub ExportButton_Click()
    > Dim fHand As Long, expCode As Variant
    >
    > fHand = FreeFile
    > Open ExportName For Output As fHand
    >
    > Write #fHand, TextBox 'TextBox included text "[Example]"
    > Write #fHand, "key_temp="
    >
    > For Each expCode In Range(CodeRef)
    > Write #fHand, 1, expCode
    > Next expCode
    >
    > Close fHand
    > End Sub
    >
    > --------
    > I want export content should like this
    >
    > [Example]
    > key_temp=1,000690;1,000063;1,000022;1,000829;0,600001;0,600005;0,000001;1,39
    > 9001;
    >
    > --------
    > But now is this.
    >
    > "[Example]"
    > "key_temp="
    > 1,"000633"
    > 1,"000830"
    > 1,"000056"
    > 1,"000407"
    > 1,"000806"
    > 1,"000860"
    > 1,"000881"
    > 1,"000850"
    > 1,"000928"
    > 1,"000717"
    >
    > --------
    > How to remove the quotation mark?
    > how i export the ';' semicolon mark?
    >
    > Thanks a lot.


    --

    Dave Peterson

  3. #3
    Cactus
    Guest

    Re: Export to Text file.


    Dave

    Thanks.




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1