#1   Report Post  
Lois
 
Posts: n/a
Default Macro-Save as

I need to know how to 'default' the save file type as an .xls from a .dat
within a macro. After a macro has completed changing many .dat files into
excel spreadsheets to include subtotals, the file type is defaulted to .dat
and when I go to save the file, I have to constantly change the file type
from .dat to .xls.
  #2   Report Post  
bigwheel
 
Posts: n/a
Default

"Lois" wrote:

I need to know how to 'default' the save file type as an .xls from a .dat
within a macro. After a macro has completed changing many .dat files into
excel spreadsheets to include subtotals, the file type is defaulted to .dat
and when I go to save the file, I have to constantly change the file type
from .dat to .xls.


Check the SaveAs method which allows you to specify the desired FileFormat
e.g.
ActiveWorkbook.SaveAs(test, fileFormat:=xlNormal)
  #3   Report Post  
bigwheel
 
Posts: n/a
Default

"bigwheel" wrote:

"Lois" wrote:

I need to know how to 'default' the save file type as an .xls from a .dat
within a macro. After a macro has completed changing many .dat files into
excel spreadsheets to include subtotals, the file type is defaulted to .dat
and when I go to save the file, I have to constantly change the file type
from .dat to .xls.


Check the SaveAs method which allows you to specify the desired FileFormat
e.g.
ActiveWorkbook.SaveAs(test, fileFormat:=xlNormal)


Sorry, bit of an error with the syntax above ...

Try ActiveWorkbook.SaveAs FileFormat:=xlNormal
  #4   Report Post  
Lois
 
Posts: n/a
Default

Thanks, but I'm still having trouble. I probably wasn't very clear before.
Here is the macro that we currently have and need to change to include
'changing the file type from .dat to .xls. before we save the file.
Any help is appreciated!!!

SendKeys "%fa~"
ActiveSheet.Outline.ShowLevels Rowlevels:=4
Columns("B:E").Select
Selection.EntireColumn.Hidden = True
Columns("G:T").Select
Selection.EntireColumn.Hidden = True
ActiveSheet.PrintOut
SendKeys "n~"
ActiveWindow.Close
End Sub



"bigwheel" wrote:

"bigwheel" wrote:

"Lois" wrote:

I need to know how to 'default' the save file type as an .xls from a .dat
within a macro. After a macro has completed changing many .dat files into
excel spreadsheets to include subtotals, the file type is defaulted to .dat
and when I go to save the file, I have to constantly change the file type
from .dat to .xls.


Check the SaveAs method which allows you to specify the desired FileFormat
e.g.
ActiveWorkbook.SaveAs(test, fileFormat:=xlNormal)


Sorry, bit of an error with the syntax above ...

Try ActiveWorkbook.SaveAs FileFormat:=xlNormal

  #5   Report Post  
bigwheel
 
Posts: n/a
Default

OK see if this helps. Change ActiveWindow.Close to

a = ActiveWindow.Close(True,awName)

Insert immediately above this, and all on one line, as follows:-

awname = Left(ActiveWorkbook.Name, Application.WorksheetFunction.Find(".",
ActiveWorkbook.Name) - 1) & ".xls"



"Lois" wrote:

Thanks, but I'm still having trouble. I probably wasn't very clear before.
Here is the macro that we currently have and need to change to include
'changing the file type from .dat to .xls. before we save the file.
Any help is appreciated!!!

SendKeys "%fa~"
ActiveSheet.Outline.ShowLevels Rowlevels:=4
Columns("B:E").Select
Selection.EntireColumn.Hidden = True
Columns("G:T").Select
Selection.EntireColumn.Hidden = True
ActiveSheet.PrintOut
SendKeys "n~"
ActiveWindow.Close
End Sub



"bigwheel" wrote:

"bigwheel" wrote:

"Lois" wrote:

I need to know how to 'default' the save file type as an .xls from a .dat
within a macro. After a macro has completed changing many .dat files into
excel spreadsheets to include subtotals, the file type is defaulted to .dat
and when I go to save the file, I have to constantly change the file type
from .dat to .xls.

Check the SaveAs method which allows you to specify the desired FileFormat
e.g.
ActiveWorkbook.SaveAs(test, fileFormat:=xlNormal)


Sorry, bit of an error with the syntax above ...

Try ActiveWorkbook.SaveAs FileFormat:=xlNormal



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
Macro excel save mrbalaje Excel Discussion (Misc queries) 1 May 12th 05 06:27 PM
macro to save file automaticaly? david Excel Discussion (Misc queries) 1 May 6th 05 05:21 PM
Save Macro - yet another question Roger Excel Discussion (Misc queries) 4 April 14th 05 09:28 PM
How to stop getting the file save box when running a macro Pank Mehta Excel Discussion (Misc queries) 1 March 29th 05 04:05 PM
Macro in Excel 2002 to save a workbook to a FTP location Lloyd Excel Discussion (Misc queries) 0 December 21st 04 02:49 PM


All times are GMT +1. The time now is 05:01 PM.

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"