Saving as Text without delimeters

jhall07

New Member
Joined
Apr 29, 2014
Messages
9
I am trying to save an worksheet as txt format. Everytime I try to perform this, I am getting quotation marks around each line that includes a comma. So I tried saving it as .prn to avoid the quotation marks. Now, it cuts off any line that has more than 250 characters. Is there any text format that I save my file as that will not add quotations or limit line lengths?:confused:
 
The macro currently starts on workbook A, which then moves the data that I want to a new workbook (workbook B). I have been saving workbook B as a txt file. I am not familiar with Freefile(), but if this would work with everything being in one workbook then I can modify my macro to stay in original workbook (A). And yes, there could be anywhere from 20-1000 rows in column A.
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
The macro currently starts on workbook A, which then moves the data that I want to a new workbook (workbook B). I have been saving workbook B as a txt file. I am not familiar with Freefile(), but if this would work with everything being in one workbook then I can modify my macro to stay in original workbook (A). And yes, there could be anywhere from 20-1000 rows in column A.
The code, as written, expects the data to be in the same workbook as the macro containing my code. Here is the code modified to work from your current code's location... it will look in "Sheet1" (change as necessary) of the already open workbook named "Workbook B.xlsx" (change to your actual workbooks name) located in the directory that you assigned to the strFolder variable and with the main file name that you assigned to the fname variable.
Code:
  FF = FreeFile()
  Open strFolder & fname & ".properties" & ".txt" For Output As #FF
  With Workbooks("[COLOR=#FF0000][B]Workbook B.xlsx[/B][/COLOR]").Sheets("[COLOR=#FF0000][B]Sheet1[/B][/COLOR]")
    Print #FF, Join(Application.Transpose(.Range("A1", .Cells(Rows.Count, "A").End(xlUp)).Value), vbNewLine)
  End With
  Close #FF
 
Upvote 0
I converted my macro to do everything in one workbook. I am still getting the same runtime error 13: Type Mismatch. One note, not sure if it matters, but the output file is being created not opened. Once it is generated it is automatically pulled out of the directory by another job that runs. So every time this macro runs, it creates a new file from scratch. I added some other code from my macro that pertain to other variables of the code you provided. Maybe it will help with a solution. I appreciate your help with this. I have been trying to research ideas/solutions for about 4 days now.

Code:
'Choose file save location    
    Dim strFolder As String
    Set fd = Application.FileDialog(msoFileDialogFolderPicker)
    With fd
        .Title = "Select the folder into which the documents will be saved."
        If .Show = -1 Then
            strFolder = .SelectedItems(1) & "\"
        Else
         MsgBox "The documents will be saved in the default document file location."
        strFolder = ""
    End If
    End With

'Store file name
    Dim fname As String
    fname = Worksheets("Export").Cells(9, "B").Value

'Save the file
    Dim FF As Long
    FF = FreeFile()
    Open strFolder & fname & ".properties" & ".txt" For Output As #FF
    Print #FF, Join(Application.Transpose(Range("A1", Cells(Rows.Count, "A").End(xlUp)).Value), vbNewLine)
    Close #FF
 
Upvote 0
I converted my macro to do everything in one workbook. I am still getting the same runtime error 13: Type Mismatch.
Can you send me a copy of that workbook with the full macro in place so I can run/debug it firsthand? I really think that would be easier than for me to keep guessing at possible problems until, perhaps, I got lucky and stumbled over the problem. My email address is...

rick DOT news AT verizon DOT net

Please include this thread's title in the email so I can more easily find my way back here.
 
Upvote 0
Can you send me a copy of that workbook with the full macro in place so I can run/debug it firsthand? I really think that would be easier than for me to keep guessing at possible problems until, perhaps, I got lucky and stumbled over the problem. My email address is...

rick DOT news AT verizon DOT net

Please include this thread's title in the email so I can more easily find my way back here.

I sent you an email with the workbook attached. Let me know if you don't receive it.
 
Upvote 0
I sent you an email with the workbook attached. Let me know if you don't receive it.
Sorry for not getting back to you yet... my computer has been having some kind of problem over the last couple of days. When I tried to downloaded your file, Outlook crashed. As it turned out, your file, itself, was not at fault... it was just coincidental that downloading it kicked-off whatever the problem was, but the end result was I lost two of my four Outlook email accounts. I think I got everything straightened out... for now (I still don't know what caused the problem originally, but things appear to finally be stable right now). I have been unable to participate in this forum until now, so I now have some "catching up" to do. I'll be back here later today with (hopefully) a solution to your problem.
 
Upvote 0
I sent you an email with the workbook attached. Let me know if you don't receive it.
Okay, the problem was that I used the Transpose function, which as a 255 character limit for the cells it can process, and you have several cells with well more than 255 characters in it. So, you will need to use the code below, which does not have this limit, in place of the code I gave you earlier...
Code:
  Dim X As Long, FF As Long, Data As Variant, CombinedText As String
  '....
  '....
  '....
  Data = Sheets("export_sheet").Range("A1", Cells(Rows.Count, "A").End(xlUp))
  For X = 1 To UBound(Data)
    CombinedText = CombinedText & vbNewLine & Data(X, 1)
  Next
  CombinedText = Mid(CombinedText, Len(vbNewLine) + 1)
  FF = FreeFile()
  Open strFolder & fname & ".properties" & ".txt" For Output As #FF
  Print #FF, CombinedText
  Close #FF
 
Upvote 0
Keep it simple:

Code:
Sub M_snb()
   ActiveSheet.UsedRange.Columns(1).Copy
  
   With GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
     .GetFromClipboard
     CreateObject("scripting.filesystemobject").createtextfile("G:\OF\example.txt").write .GetText
   End With
End Sub
 
Upvote 0
Keep it simple:

Code:
   With GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")

I am not sure if the word "simple" is the correct word to use when making use of a "mysterious" GUID like that. :wink:
 
Upvote 0

Forum statistics

Threads
1,215,455
Messages
6,124,935
Members
449,195
Latest member
Stevenciu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top