Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open CSV file, format data and write output to a text file. BristolBloos Excel Programming 1 October 18th 05 03:50 PM
Create and write a simple text file in Excel/VBA Thomas Wieser Excel Programming 4 April 13th 04 10:24 AM
opening and write to a text file in excel julian brotherton Excel Programming 1 October 5th 03 11:13 PM
write a line from Excel to a text file julian_bro Excel Programming 1 September 30th 03 01:29 AM
VB6 - ADO - Excel XP, cell formated as text [email protected] Excel Programming 0 September 15th 03 03:38 PM


All times are GMT +1. The time now is 05:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"