Problem writing cell contents to text file

ronnyfo

New Member
Joined
Jun 26, 2007
Messages
18
I have written a macro which generate a report configuration file (for Safran Project)
the configuration file looks fine in Excel - however when i save it as Tab-separated text file it converts one particular cell contents into a string of #'s
The cell content is only as follows:
000000070000000000000000080100000000000000060000000000000035110100100110320400000000000002011000010300000350000300000080000000000100Times New Roman 0000000000Times New Roman 0000000000Times New Roman 0000000000Times New Roman 0000000000Times New Roman 0000000000Times New Roman 0000000000Times New Roman 0000000000Times New Roman 0000000000Times New Roman 0000000000Times New Roman 0000000000Times New Roman 0000000000Times New Roman 0000000000Times New Roman 0000000000000001677721500167772150016777215<Timenow>


Is there any quick fixes to make Excel write this to the file, instead of #'s
(without having to re-write the macro to write one and one character to the file?)
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Could you post the code you're using. I tried to reproduce the problem but I couldn't. This is the code I used to test
Code:
Sub Macro1()

    Dim reportPath As String
    Dim tempPath As String
    Dim wb As Workbook
    Dim wbCopy As Workbook
    
    Set wb = ActiveWorkbook
    
    reportPath = wb.Path & "\" & "TabDeliminated.txt"
    tempPath = Environ("Temp") & "\" & Format(Now, "HHMMSS") & wb.Name
    
    wb.SaveCopyAs tempPath
    
    Set wbCopy = Workbooks.Open(tempPath)
    
    Application.DisplayAlerts = False
    wbCopy.Saveas Filename:=reportPath, FileFormat:=xlText, CreateBackup:=False
    Application.DisplayAlerts = True
    
    wbCopy.Close SaveChanges:=False
    Kill tempPath
    wb.Activate
End Sub
 
Upvote 0
Actually i managed to solve the problem late last night.
Originally I had formatted the cell in question as Text, but formatting the cell to General before I save to file, the problem was solved.

Thanks anyway :)
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,484
Members
452,917
Latest member
MrsMSalt

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