p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Excel VBA (http://p2p.wrox.com/forumdisplay.php?f=79)
-   -   Exporting cell values to text file (http://p2p.wrox.com/showthread.php?t=62478)

vemaju October 1st, 2007 04:57 AM

Exporting cell values to text file
 
Hi,

I have a table and I want to convert it to txt-file
I use this code and everything is fine

Sub WriteTxtFile()
Dim File As String
Dim FileNum As Integer


FileNum = FreeFile
'File = "C:\Sample\Output.tmp"
'*** Kill previous File
On Error Resume Next
Kill File
On Error GoTo 0

Open File For Append As #FileNum

    Write #FileNum, Sheets("Sheet1").Range("B11") & ", " & "Sheet1" & ", " & "B11"
    Write #FileNum, Sheets("Sheet1").Range("B12") & ", " & "Sheet1" & ", " & "B12"
    Write #FileNum, Sheets("Sheet1").Range("B13") & ", " & "Sheet1" & ", " & "B13"
Close #FileNum

End Sub

Result
"Test, Sheet1, B11"
"Test1, Sheet1, B12"
"Test2, Sheet1, B13"

Problem is that I want the result file without quotation marks (")

Any ideas ?



-vemaju

tweakmeister October 1st, 2007 01:43 PM

See if this helps: http://www.microsoft.com/technet/scr...5/hey0606.mspx

--




vemaju October 1st, 2007 02:30 PM

Hi,

That was the trick. Thank you.

-vemaju


All times are GMT -4. The time now is 07:54 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.