Posted to microsoft.public.excel.programming
|
|
How to generate a text file from Excel using a macro or script
Daer Ron,
Your code solves my problem but the thing is it prints only the first row of
the sheet how do I print many rows?
Please reply!
Thanks!
-Frank-
"Frank" wrote:
Dear Ron,
ooops!
Thanks a lot!
I got what I wanted!
U made my life easy!
Thank you very much again!
Frank
"Ron de Bruin" wrote:
This will open the file after it create it
Is that what you want ?
Public Sub TextNoModification()
Const DELIMITER As String = "," 'or "|", vbTab, etc.
Dim myRecord As Range
Dim myField As Range
Dim nFileNum As Long
Dim sOut As String
nFileNum = FreeFile
Open "Test.txt" For Output As #nFileNum
For Each myRecord In Range("A1:A" & _
Range("A" & Rows.Count).End(xlUp).Row)
With myRecord
For Each myField In Range(.Cells(1), _
Cells(.Row, Columns.Count).End(xlToLeft))
sOut = sOut & DELIMITER & myField.Text
Next myField
Print #nFileNum, Mid(sOut, 2)
sOut = Empty
End With
Next myRecord
Close #nFileNum
Shell "notepad.exe Test.txt", vbNormalFocus
End Sub
--
Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm
"Frank" wrote in message ...
dear Ron,
Thanks a lot for your guiding I went through the page you showed me!
And now I know where to copy and paste!
but I neet to create a button in da excel sheet and then get da text data
file open when clicked. I know to create a button on the excel sheet but I am
scared to mention I still have problems with the code!
Can U kindly help me with this?
Thanks!
"Ron de Bruin" wrote:
I answer this in your other thread
Please post in one group
http://www.mcgimpsey.com/excel/textfiles.html
--
Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm
"Frank" wrote in message ...
I need to know the way of generating a text file from data availbabe in an
Excel spreadsheet either using a Macro or a Script!
Asume if I have some data in few cells such as C5, C6 and C7
then if I have a simple formula like Sum in another cell like C8 to get the
total of the above mentioned cells. How do I display the values in those
cells in a text file generated by a macro or script?
Please be kind enough to reply me if you know this!
Thanks a lot!
-Frank-
|