+ Reply to Thread
Results 1 to 2 of 2

Write formated excel values into text file

  1. #1
    kaiserlich
    Guest

    Write formated excel values into text file

    Hi there,

    i try to write a selected range by a user into a .txt file.

    Here is the code:

    Sub WriteFile()

    Dim OutputFile As String
    OutputFile = "C:\test.txt"

    Dim myRange As Range
    Set myRange = Selection

    Open OutputFile For Output As #1

    For Each rngCell In myRange.Cells

    inhalt = Cells(rngCell.Row, rngCell.Column).Value
    'inhalt = Mid(inhalt, 2, 2)

    Print #1, inhalt

    Next rngCell

    Close #1

    End Sub


    All text values are written well. But for example:

    Excel value: 10:15:00 AM
    Text File value: 0.427083333333333

    How can i make that he writes the proper values?

    Thank you for help!

    greetz
    kaiserlich

  2. #2
    Alok
    Guest

    RE: Write formated excel values into text file

    Hi
    Use .Text rather than .Value
    Alok

    "kaiserlich" wrote:

    > Hi there,
    >
    > i try to write a selected range by a user into a .txt file.
    >
    > Here is the code:
    >
    > Sub WriteFile()
    >
    > Dim OutputFile As String
    > OutputFile = "C:\test.txt"
    >
    > Dim myRange As Range
    > Set myRange = Selection
    >
    > Open OutputFile For Output As #1
    >
    > For Each rngCell In myRange.Cells
    >
    > inhalt = Cells(rngCell.Row, rngCell.Column).Value
    > 'inhalt = Mid(inhalt, 2, 2)
    >
    > Print #1, inhalt
    >
    > Next rngCell
    >
    > Close #1
    >
    > End Sub
    >
    >
    > All text values are written well. But for example:
    >
    > Excel value: 10:15:00 AM
    > Text File value: 0.427083333333333
    >
    > How can i make that he writes the proper values?
    >
    > Thank you for help!
    >
    > greetz
    > kaiserlich


+ 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