Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Saving a file

I have the following statements:

DataFileName = Application.GetOpenFilename(fileFilter:="Text or ASC Files,
*.txt; *.asc", Title:="Select the Data File")

....code

'Saves The File (As Sheetx) And Leaves It Open
ActiveWorkbook.SaveAs

'Saves File As DataFileName But With The Extension Of the File Opened TXT
Format And Not In Excel Format
ActiveWorkbook.SaveAs (DataFileName)

'Receive Syntax Error
ActiveWorkbook.SaveAs (DataFileName, FileFormat:="Excel (*.xls), *.xls")

What am I missing?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Saving a file

fileformat is not like the filefilter--where you want to give a choice.

You tell excel the format you want to use:

ActiveWorkbook.SaveAs DataFileName, FileFormat:=xlworkbooknormal

See VBA's help for all the different fileformats you can use.

Dan wrote:

I have the following statements:

DataFileName = Application.GetOpenFilename(fileFilter:="Text or ASC Files,
*.txt; *.asc", Title:="Select the Data File")

...code

'Saves The File (As Sheetx) And Leaves It Open
ActiveWorkbook.SaveAs

'Saves File As DataFileName But With The Extension Of the File Opened TXT
Format And Not In Excel Format
ActiveWorkbook.SaveAs (DataFileName)

'Receive Syntax Error
ActiveWorkbook.SaveAs (DataFileName, FileFormat:="Excel (*.xls), *.xls")

What am I missing?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Saving a file

This does not work. Excel still wants to save the file as DataFileName type
and overwrite the txt file and not create a "xls" file.

"Dave Peterson" wrote:

fileformat is not like the filefilter--where you want to give a choice.

You tell excel the format you want to use:

ActiveWorkbook.SaveAs DataFileName, FileFormat:=xlworkbooknormal

See VBA's help for all the different fileformats you can use.

Dan wrote:

I have the following statements:

DataFileName = Application.GetOpenFilename(fileFilter:="Text or ASC Files,
*.txt; *.asc", Title:="Select the Data File")

...code

'Saves The File (As Sheetx) And Leaves It Open
ActiveWorkbook.SaveAs

'Saves File As DataFileName But With The Extension Of the File Opened TXT
Format And Not In Excel Format
ActiveWorkbook.SaveAs (DataFileName)

'Receive Syntax Error
ActiveWorkbook.SaveAs (DataFileName, FileFormat:="Excel (*.xls), *.xls")

What am I missing?


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Saving a file

You sure? Try opening that file in Notepad--I bet it looks greek to you.

It'll overwrite the existing file name with a real excel workbook--but that
workbook has an extension of .txt (or .asc).

If you want to strip the last 4 characters from the name, you can use:

datafilename = left(datafilename,len(datafilename)-4) & ".xls"

ActiveWorkbook.SaveAs DataFileName, FileFormat:=xlworkbooknormal

And you'll have a file that ends with .xls.



Dan wrote:

This does not work. Excel still wants to save the file as DataFileName type
and overwrite the txt file and not create a "xls" file.

"Dave Peterson" wrote:

fileformat is not like the filefilter--where you want to give a choice.

You tell excel the format you want to use:

ActiveWorkbook.SaveAs DataFileName, FileFormat:=xlworkbooknormal

See VBA's help for all the different fileformats you can use.

Dan wrote:

I have the following statements:

DataFileName = Application.GetOpenFilename(fileFilter:="Text or ASC Files,
*.txt; *.asc", Title:="Select the Data File")

...code

'Saves The File (As Sheetx) And Leaves It Open
ActiveWorkbook.SaveAs

'Saves File As DataFileName But With The Extension Of the File Opened TXT
Format And Not In Excel Format
ActiveWorkbook.SaveAs (DataFileName)

'Receive Syntax Error
ActiveWorkbook.SaveAs (DataFileName, FileFormat:="Excel (*.xls), *.xls")

What am I missing?


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Saving a file

Without the xls extension it would not have been intuitive to others that the
file can be opened by excel. Also if the original data was needed (without
modifications) this would be lost.

Thanks I had just finished implementing the statement:

datafilename = left(datafilename,len(datafilename)-4) & ".xls"

when you post appeared.

"Dave Peterson" wrote:

You sure? Try opening that file in Notepad--I bet it looks greek to you.

It'll overwrite the existing file name with a real excel workbook--but that
workbook has an extension of .txt (or .asc).

If you want to strip the last 4 characters from the name, you can use:

datafilename = left(datafilename,len(datafilename)-4) & ".xls"

ActiveWorkbook.SaveAs DataFileName, FileFormat:=xlworkbooknormal

And you'll have a file that ends with .xls.



Dan wrote:

This does not work. Excel still wants to save the file as DataFileName type
and overwrite the txt file and not create a "xls" file.

"Dave Peterson" wrote:

fileformat is not like the filefilter--where you want to give a choice.

You tell excel the format you want to use:

ActiveWorkbook.SaveAs DataFileName, FileFormat:=xlworkbooknormal

See VBA's help for all the different fileformats you can use.

Dan wrote:

I have the following statements:

DataFileName = Application.GetOpenFilename(fileFilter:="Text or ASC Files,
*.txt; *.asc", Title:="Select the Data File")

...code

'Saves The File (As Sheetx) And Leaves It Open
ActiveWorkbook.SaveAs

'Saves File As DataFileName But With The Extension Of the File Opened TXT
Format And Not In Excel Format
ActiveWorkbook.SaveAs (DataFileName)

'Receive Syntax Error
ActiveWorkbook.SaveAs (DataFileName, FileFormat:="Excel (*.xls), *.xls")

What am I missing?

--

Dave Peterson


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Saving a file

Oh, I agree with your assessment. I wouldn't change the extension of a normal
workbook from .xls unless I had a very, very good reason.

But when I first read your initial post, I focused like a laser beam <vbg on
the fileformat portion--not the extension portion.



Dan wrote:

Without the xls extension it would not have been intuitive to others that the
file can be opened by excel. Also if the original data was needed (without
modifications) this would be lost.

Thanks I had just finished implementing the statement:

datafilename = left(datafilename,len(datafilename)-4) & ".xls"

when you post appeared.

"Dave Peterson" wrote:

You sure? Try opening that file in Notepad--I bet it looks greek to you.

It'll overwrite the existing file name with a real excel workbook--but that
workbook has an extension of .txt (or .asc).

If you want to strip the last 4 characters from the name, you can use:

datafilename = left(datafilename,len(datafilename)-4) & ".xls"

ActiveWorkbook.SaveAs DataFileName, FileFormat:=xlworkbooknormal

And you'll have a file that ends with .xls.



Dan wrote:

This does not work. Excel still wants to save the file as DataFileName type
and overwrite the txt file and not create a "xls" file.

"Dave Peterson" wrote:

fileformat is not like the filefilter--where you want to give a choice.

You tell excel the format you want to use:

ActiveWorkbook.SaveAs DataFileName, FileFormat:=xlworkbooknormal

See VBA's help for all the different fileformats you can use.

Dan wrote:

I have the following statements:

DataFileName = Application.GetOpenFilename(fileFilter:="Text or ASC Files,
*.txt; *.asc", Title:="Select the Data File")

...code

'Saves The File (As Sheetx) And Leaves It Open
ActiveWorkbook.SaveAs

'Saves File As DataFileName But With The Extension Of the File Opened TXT
Format And Not In Excel Format
ActiveWorkbook.SaveAs (DataFileName)

'Receive Syntax Error
ActiveWorkbook.SaveAs (DataFileName, FileFormat:="Excel (*.xls), *.xls")

What am I missing?

--

Dave Peterson


--

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
Saving Excel 2007 file in 2003 creates very large file Jon Pearce Excel Discussion (Misc queries) 2 July 16th 09 07:20 PM
Text file saving, setting file origin mauddib Excel Discussion (Misc queries) 0 May 25th 06 02:50 PM
Saving multi-tab excel file created from comma delimited text file Marcus Aurelius Excel Programming 2 December 19th 05 05:16 PM
How do I stop Excel 2000 from saving file history from file that . Cathy Excel Discussion (Misc queries) 0 March 29th 05 03:27 PM
saving an excel file as an ASCII text file without delimiters Sewellst Excel Programming 4 January 7th 05 01:41 PM


All times are GMT +1. The time now is 02:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"