LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Need Solution save as ASCII

Tom,
I am a newbie in VBA.
Do I just copy and paste the code into a module...? In a separate file....
How do I actually get this going?
Tx,
S

"Tom Ogilvy" wrote in message
...
Looks like most of it came from Chip Pearson's site:

http://www.cpearson.com/excel/imptext.htm

--
Regards,
Tom Ogilvy


"Michael J. Malinsky" wrote in message
...
I'm sure I got the following code from somewhere in the NGs but I forget

who
wrote it (it wasn't me though so I can't take credit) The only thing

you
may want to change is the FName varable for the filename:

Public Sub ExportToTextFile()
Dim WholeLine As String
Dim FNum As Integer
Dim RowNdx As Long
Dim ColNdx As Integer
Dim StartRow As Long
Dim EndRow As Long
Dim StartCol As Integer
Dim EndCol As Integer
Dim CellValue As String
Dim FName As String
Dim Sep As String
Dim SelectionOnly As Boolean
FName = "testing.txt"
Sep = ","
SelectionOnly = True

Application.ScreenUpdating = False
On Error GoTo EndMacro:
FNum = FreeFile

If SelectionOnly = True Then
With Selection
StartRow = .Cells(1).Row
StartCol = .Cells(1).Column
EndRow = .Cells(.Cells.Count).Row
EndCol = .Cells(.Cells.Count).Column
End With
Else
With ActiveSheet.UsedRange
StartRow = .Cells(1).Row
StartCol = .Cells(1).Column
EndRow = .Cells(.Cells.Count).Row
EndCol = .Cells(.Cells.Count).Column
End With
End If

Open FName For Output Access Write As #FNum

For RowNdx = StartRow To EndRow
WholeLine = ""
For ColNdx = StartCol To EndCol
If Cells(RowNdx, ColNdx).Value = "" Then
CellValue = Chr(34) & Chr(34)
Else
CellValue = _
Application.WorksheetFunction.Text _
(Cells(RowNdx, ColNdx).Value, _
Cells(RowNdx, ColNdx).NumberFormat)
End If
WholeLine = WholeLine & CellValue & Sep
Next ColNdx
WholeLine = Left(WholeLine, Len(WholeLine) - Len(Sep))
Print #FNum, WholeLine
Next RowNdx

EndMacro:
On Error GoTo 0
Application.ScreenUpdating = True
Close #FNum

End Sub


--
Michael J. Malinsky
Pittsburgh, PA

"I was gratified to be able to answer promptly,
and I did. I said I didn't know." -- Mark Twain

"saturnin02" <saturnin02_at_hotmail.com wrote in message
...
XL 2002 Win XP HE

Hi, Is there a way to save the active sheet in a workbook (which

contains
only values) as a ASCII file with extension txt and ANSI encoding? In

other
words, a plain vanilla text file that would be usually created or read

in
NotePad, etc.

I have tried (obviously) all of the options to Save As....
None of them give me what the SIMPLE text format that I want: ASCII

file
with extension txt and ANSI encoding.

Tx a lot!!
S










 
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
Save Excel to ASCII format Aaron Z Excel Discussion (Misc queries) 2 July 26th 06 08:46 PM
How do I save a Word file as an ASCII format? Laurie Excel Discussion (Misc queries) 5 April 6th 06 01:31 AM
how to save Excel data as ASCII* text? Mitali Das Excel Discussion (Misc queries) 1 January 7th 06 10:35 PM
How do I save in standard ASCII format? Sudge Excel Discussion (Misc queries) 2 September 1st 05 04:44 AM
How do I save an Excel file in ASCII? Mrs Crinkle Excel Discussion (Misc queries) 2 May 20th 05 11:12 PM


All times are GMT +1. The time now is 10:31 PM.

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

About Us

"It's about Microsoft Excel"