View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Retaining formats

My suggestion is still gonna look like:

Maybe you could start a new workbook
record a macro when you open the text file
keep recording as you format your data the way you like
and then stop recording.
(and close the text file)

Then add a button from the Forms toolbar to the first worksheet in that workbook
with the recorded macro. Assign the macro to this button.

Then whenever you need to import the text file, you can open this workbook and
click the button.


grok wrote:

Dave,
So I do File|SaveAs and save the header as an Excel workbook. Now I can
open the file and see that the formatting is retained. But the app is
writing to it and I cannot see what the app is writing. So I open a copy of
it with notepad and can see what the app writes and the formated header is
greek.

I guess this means that I cannot do what I've been trying to do so the only
thing left is to try the macro. Since I have no experience with macros can
you get me started? All I want to do is: select row 1 and format|align
select wrap text; then select all cells, and select center text. Please give
me clues.

"Dave Peterson" wrote:

If you don't do anything special with #3, then it's still plain text.

But you could use File|SaveAs and choose an excel workbook (normal workbook) at
the top of the "Save as Type" box.

---
You should have gotten a warning from Excel each time you just saved the text
file. Excel will try to convince you to save it as a normal workbook--but it's
your decision to dismiss that warning message.



grok wrote:

Dave, I looked at the file with Notepad and it looked normal so it's not an
excel workbook. What happens is:

1. My app deletes the file (if it exists) and writes a header to it tab
delimited. (Not excel here)
2. I open excel and then open the file with File-Open.
3. I format the spreadsheet and save back to the same file.

Does step 3. convert the file to a worksheet? I guess not. Is there some
way to convert it to excel?

grok

"Dave Peterson" wrote:

If that application writes to a real excel workbook, then you shouldn't be
losing your formatting.

But I was confused by this:
I have an app that appends to a .xls file (tab delimited).

If that application writes to a text file with an extension of .xls, it's still
a text file. Just adding the extension isn't enough to convert the file to a
normal workbook.

If I had doubts about the real nature of that file, I'd open NotePad and then
File|Open the file that the application creates. (Do not save the file! You
could destroy it--in fact, it would be safer to do this against a copy.)

If you see plain old text in that file (while in notepad), then it's not an
excel workbook.

If you see a bunch of greek text that you can't decipher (for the most part),
then the file could be a normal excel workbook.



grok wrote:

But the app is writing the file as .xls so doesn't that make it an excel
file? I can make the app write any way I want is there some way to write so
formatting is retained?

"Dave Peterson" wrote:

If the data is saved as a text file (tab delimited), then the formatting won't
be saved.

Maybe you could start a new workbook
record a macro when you open the text file
keep recording as you format your data the way you like
and then stop recording.
(and close the text file)

Then add a button from the Forms toolbar to the first worksheet in that workbook
with the recorded macro. Assign the macro to this button.

Then whenever you need to import the text file, you can open this workbook and
click the button.

grok wrote:

I have an app that appends to a .xls file (tab delimited). I open excel and
then use File - Open to open the file read-only.

But every time I do it I have to go thru the Text Import Wizard and I lose
all my formatting. I need a way to go thru the wizard just the first time
and retaining the formatting.

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


--

Dave Peterson