Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Rob
 
Posts: n/a
Default Saving sheet to text file

Hi,
Can someone please help me with a date formatting problem.

When I save a sheet to a TXT file manually (using the SaveAs option, etc.),
I have no problems and the dates remain as they are shown on the sheet as
d/m/yy (eg 15/9/05), but when I use the following macro, the dates on that
sheet are saved to the text file as month/day/year (eg 9/15/05)

Sub ExportToMYOB()
ActiveWorkbook.Save
Sheet2.SaveAs Filename:="C:\Premier9\Data files\ExportToMYOB.txt", _
FileFormat:=xlText, CreateBackup:=False
ActiveWindow.Close
End Sub

Why is it so?

Rob


  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Saving sheet to text file

How did you verify this?

Did you open the file in a text editor (like NotePad)?

When I did save dates as a text file, the format of the date was saved:
dmy or mdy or ymd or....

But if I wasn't careful when I reopened in Excel--not NotePad, then excel would
use my pc's short date format for anything that looked like a date.

9/12/2005 was brought in as September 12, 2005--even though the original file
had a value of December 9, 2005.

I could use the text import wizard and tell excel how to treat that field,
however.



Rob wrote:

Hi,
Can someone please help me with a date formatting problem.

When I save a sheet to a TXT file manually (using the SaveAs option, etc.),
I have no problems and the dates remain as they are shown on the sheet as
d/m/yy (eg 15/9/05), but when I use the following macro, the dates on that
sheet are saved to the text file as month/day/year (eg 9/15/05)

Sub ExportToMYOB()
ActiveWorkbook.Save
Sheet2.SaveAs Filename:="C:\Premier9\Data files\ExportToMYOB.txt", _
FileFormat:=xlText, CreateBackup:=False
ActiveWindow.Close
End Sub

Why is it so?

Rob


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
Rob
 
Posts: n/a
Default Saving sheet to text file

Hi Dave,

Thankyou for your reply.

I'm simply saving the sheet as a text file and then importing the data by
another (accounting software) program, (not back to Excel).
For some reason, running the script causes the formatting to be converted to
m/d/yyyy after I export it (when it's showing, and formatted, as d/m/yyyy in
Excel) . Checking the text file, using Notepad, shows that is in the wrong
format, so I wondered if there was something peculiar with the script, as
doing it longhanded doesn't give the problem.
Does the script need something (if it was possible) to make sure the
formatting is retained?
It seems really odd to me that doing it via a macro and doing it manually
give different formats!

Just a BTW, which I can't see has any bearing, the date column contains
formulas taking the date from another sheet.

Rob

"Dave Peterson" wrote in message
...
How did you verify this?

Did you open the file in a text editor (like NotePad)?

When I did save dates as a text file, the format of the date was saved:
dmy or mdy or ymd or....

But if I wasn't careful when I reopened in Excel--not NotePad, then excel
would
use my pc's short date format for anything that looked like a date.

9/12/2005 was brought in as September 12, 2005--even though the original
file
had a value of December 9, 2005.

I could use the text import wizard and tell excel how to treat that field,
however.



Rob wrote:

Hi,
Can someone please help me with a date formatting problem.

When I save a sheet to a TXT file manually (using the SaveAs option,
etc.),
I have no problems and the dates remain as they are shown on the sheet as
d/m/yy (eg 15/9/05), but when I use the following macro, the dates on
that
sheet are saved to the text file as month/day/year (eg 9/15/05)

Sub ExportToMYOB()
ActiveWorkbook.Save
Sheet2.SaveAs Filename:="C:\Premier9\Data files\ExportToMYOB.txt", _
FileFormat:=xlText, CreateBackup:=False
ActiveWindow.Close
End Sub

Why is it so?

Rob


--

Dave Peterson



  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Saving sheet to text file

I'm sorry, I don't have a followup guess.

It worked fine for me when I did it.

Maybe you could just write out the values the way you want.

Earl Kiosterud's Text Write program:
www.smokeylake.com/excel
(or directly: http://www.smokeylake.com/excel/text_write_program.htm)

Chip Pearson's:
http://www.cpearson.com/excel/imptext.htm

J.E. McGimpsey's:
http://www.mcgimpsey.com/excel/textfiles.html

Rob wrote:

Hi Dave,

Thankyou for your reply.

I'm simply saving the sheet as a text file and then importing the data by
another (accounting software) program, (not back to Excel).
For some reason, running the script causes the formatting to be converted to
m/d/yyyy after I export it (when it's showing, and formatted, as d/m/yyyy in
Excel) . Checking the text file, using Notepad, shows that is in the wrong
format, so I wondered if there was something peculiar with the script, as
doing it longhanded doesn't give the problem.
Does the script need something (if it was possible) to make sure the
formatting is retained?
It seems really odd to me that doing it via a macro and doing it manually
give different formats!

Just a BTW, which I can't see has any bearing, the date column contains
formulas taking the date from another sheet.

Rob

"Dave Peterson" wrote in message
...
How did you verify this?

Did you open the file in a text editor (like NotePad)?

When I did save dates as a text file, the format of the date was saved:
dmy or mdy or ymd or....

But if I wasn't careful when I reopened in Excel--not NotePad, then excel
would
use my pc's short date format for anything that looked like a date.

9/12/2005 was brought in as September 12, 2005--even though the original
file
had a value of December 9, 2005.

I could use the text import wizard and tell excel how to treat that field,
however.



Rob wrote:

Hi,
Can someone please help me with a date formatting problem.

When I save a sheet to a TXT file manually (using the SaveAs option,
etc.),
I have no problems and the dates remain as they are shown on the sheet as
d/m/yy (eg 15/9/05), but when I use the following macro, the dates on
that
sheet are saved to the text file as month/day/year (eg 9/15/05)

Sub ExportToMYOB()
ActiveWorkbook.Save
Sheet2.SaveAs Filename:="C:\Premier9\Data files\ExportToMYOB.txt", _
FileFormat:=xlText, CreateBackup:=False
ActiveWindow.Close
End Sub

Why is it so?

Rob


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
Rob
 
Posts: n/a
Default Saving sheet to text file

Thanks Dave.

After my last post I thought I'd check the formatting again, and find that
even though the date is presented as d/m/yyyy, the formatting was showing
General. I used the custom formatting option to set it at d/m/yyyy and
exported it via the macro without a problem. Phew! It was really starting
to bother me!!

I still can't understand why I got the different result between macro and
non macro saving to text file, but I'm happy it's working.

Sorry if you wasted your time on this.

Rob

"Dave Peterson" wrote in message
...
I'm sorry, I don't have a followup guess.

It worked fine for me when I did it.

Maybe you could just write out the values the way you want.

Earl Kiosterud's Text Write program:
www.smokeylake.com/excel
(or directly: http://www.smokeylake.com/excel/text_write_program.htm)

Chip Pearson's:
http://www.cpearson.com/excel/imptext.htm

J.E. McGimpsey's:
http://www.mcgimpsey.com/excel/textfiles.html

Rob wrote:

Hi Dave,

Thankyou for your reply.

I'm simply saving the sheet as a text file and then importing the data by
another (accounting software) program, (not back to Excel).
For some reason, running the script causes the formatting to be converted
to
m/d/yyyy after I export it (when it's showing, and formatted, as d/m/yyyy
in
Excel) . Checking the text file, using Notepad, shows that is in the
wrong
format, so I wondered if there was something peculiar with the script, as
doing it longhanded doesn't give the problem.
Does the script need something (if it was possible) to make sure the
formatting is retained?
It seems really odd to me that doing it via a macro and doing it manually
give different formats!

Just a BTW, which I can't see has any bearing, the date column contains
formulas taking the date from another sheet.

Rob

"Dave Peterson" wrote in message
...
How did you verify this?

Did you open the file in a text editor (like NotePad)?

When I did save dates as a text file, the format of the date was saved:
dmy or mdy or ymd or....

But if I wasn't careful when I reopened in Excel--not NotePad, then
excel
would
use my pc's short date format for anything that looked like a date.

9/12/2005 was brought in as September 12, 2005--even though the
original
file
had a value of December 9, 2005.

I could use the text import wizard and tell excel how to treat that
field,
however.



Rob wrote:

Hi,
Can someone please help me with a date formatting problem.

When I save a sheet to a TXT file manually (using the SaveAs option,
etc.),
I have no problems and the dates remain as they are shown on the sheet
as
d/m/yy (eg 15/9/05), but when I use the following macro, the dates on
that
sheet are saved to the text file as month/day/year (eg 9/15/05)

Sub ExportToMYOB()
ActiveWorkbook.Save
Sheet2.SaveAs Filename:="C:\Premier9\Data files\ExportToMYOB.txt",
_
FileFormat:=xlText, CreateBackup:=False
ActiveWindow.Close
End Sub

Why is it so?

Rob

--

Dave Peterson


--

Dave Peterson



Reply
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
Issues with saving text file Shane Malden Excel Worksheet Functions 0 October 25th 05 04:37 PM
Improrting Text file to a matrix when things are not constant. underdrain Excel Worksheet Functions 0 September 28th 05 04:00 AM
Exporting excel to text file Exceluser Excel Discussion (Misc queries) 1 June 22nd 05 11:26 PM
saving excel file as tab delimited Craig Hilliard Excel Discussion (Misc queries) 0 February 1st 05 10:39 PM
Hyperlink to specific sheet in Excel Web File jd17 Links and Linking in Excel 0 December 8th 04 09:03 PM


All times are GMT +1. The time now is 11:09 AM.

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"