Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
I need to export from Excel a large table in text format, and I cannot use either tab or comma. I am aware of these solutions: 1- http://www.cpearson.com/excel/imptext.htm#Export (which kind-of- works but has a problem with size); 2- changes in regional settings (problem with impact on other lists, etc.) Preferably I would like to use a column delimiter ALT-028 and a row delimiter ALT-030 (both invisible and cannot be typed). Is there a solution to this problem? I do not use Excel often and I do not know VBA programming, and since this is a one time issue, I cannot afford to learn it now. This is why I am addressing the experts in this group. I believe my problem should be common enough to have been solved by now. "There is no solution to this problem" is also an acceptable answer, I just need to know. Many thanks in advance, - Mike Ov. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try something like this:
Sub StringToTextFile(ByVal txtFile As String, _ ByVal strString As String) Dim hFile As Long hFile = FreeFile 'Close before reopening in another mode. '--------------------------------------- On Error Resume Next Open txtFile For Input As hFile Close #hFile Open txtFile For Output As hFile 'Write #hFile, strString 'this will make start- and end quotes Print #hFile, strString; Close #hFile End Sub Sub Range2Text(rng As Range, _ strFile As String, _ Optional strColumnDelimiter As String = ",", _ Optional strRowDelimiter As String = vbCrLf) Dim r As Long Dim c As Long Dim arr Dim UB1 As Long Dim UB2 As Long Dim str As String arr = rng UB1 = UBound(arr) UB2 = UBound(arr, 2) For r = 1 To UB1 If r = 1 Then For c = 1 To UB2 If c = 1 Then str = arr(r, c) Else str = str & strColumnDelimiter & arr(r, c) End If Next c Else For c = 1 To UB2 If c = 1 Then str = str & arr(r, c) Else str = str & strColumnDelimiter & arr(r, c) End If Next c End If str = str & strRowDelimiter Next r StringToTextFile strFile, str End Sub Sub test() Range2Text Range(Cells(1), Cells(3, 3)), "C:\Test.txt" End Sub Not sure now how to tell VBA you want ALT-028 and ALT-030, but that should be simple and you probably know. RBS wrote in message ps.com... Hi all, I need to export from Excel a large table in text format, and I cannot use either tab or comma. I am aware of these solutions: 1- http://www.cpearson.com/excel/imptext.htm#Export (which kind-of- works but has a problem with size); 2- changes in regional settings (problem with impact on other lists, etc.) Preferably I would like to use a column delimiter ALT-028 and a row delimiter ALT-030 (both invisible and cannot be typed). Is there a solution to this problem? I do not use Excel often and I do not know VBA programming, and since this is a one time issue, I cannot afford to learn it now. This is why I am addressing the experts in this group. I believe my problem should be common enough to have been solved by now. "There is no solution to this problem" is also an acceptable answer, I just need to know. Many thanks in advance, - Mike Ov. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
converting pdf to excel, no delimiters | Excel Discussion (Misc queries) | |||
How to Export as text file with NO delimiters or modifications? | Excel Discussion (Misc queries) | |||
How can I assign delimiters to an excel web query? | Excel Discussion (Misc queries) | |||
How can I assign delimiters to an excel web query? | Excel Discussion (Misc queries) | |||
Export (or save as) .csv with text delimiters | Excel Discussion (Misc queries) |