ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Saving text file in excel format through macro... (https://www.excelbanter.com/excel-programming/301229-saving-text-file-excel-format-through-macro.html)

Trevor[_4_]

Saving text file in excel format through macro...
 
Hello All,

I am using a macro that imports a text file, manipulates
it and then saves it as an excel workbook. Right now, it
is displaying the SaveAs dialog box and the user manually
navigates to the location they want to save the file, then
changes the saveAs file type box and clicks save.

Two questions:
1) Can I have the SaveAs dialog box default the SaveAs
file type to 'Excel Workbook'?

2) Can I have the whole SaveAs process happen without the
dialog box popping up?


(I tried doing:

ThisWorkbook.SaveAs FileName:="Testing.xls"

but it saves the file that I have the macro in, not the
text file that was imported.)

Any help would be much appreciated,

Trevor

sbell

Saving text file in excel format through macro...
 
Trevor,

This works where FN = path and name of the file

'''''''''''''''''''''''''''''''''''''''''''''
ActiveWorkbook.SaveAs Filename:=FN & "xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
'''''''''''''''''''''''''''''''''''''''''''''
steve

"Trevor" wrote in message
...
Hello All,

I am using a macro that imports a text file, manipulates
it and then saves it as an excel workbook. Right now, it
is displaying the SaveAs dialog box and the user manually
navigates to the location they want to save the file, then
changes the saveAs file type box and clicks save.

Two questions:
1) Can I have the SaveAs dialog box default the SaveAs
file type to 'Excel Workbook'?

2) Can I have the whole SaveAs process happen without the
dialog box popping up?


(I tried doing:

ThisWorkbook.SaveAs FileName:="Testing.xls"

but it saves the file that I have the macro in, not the
text file that was imported.)

Any help would be much appreciated,

Trevor




No Name

Saving text file in excel format through macro...
 
Steve,

I am much appreciative for your help. Who
knew "ActiveWorkbook" would be so different
from "ThisWorkbook"?

Thanks Again,

Trevor

-----Original Message-----
Trevor,

This works where FN = path and name of the file

'''''''''''''''''''''''''''''''''''''''''''''
ActiveWorkbook.SaveAs Filename:=FN & "xls", _
FileFormat:=xlNormal, Password:="",

WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
'''''''''''''''''''''''''''''''''''''''''''''
steve

"Trevor" wrote in

message
...
Hello All,

I am using a macro that imports a text file, manipulates
it and then saves it as an excel workbook. Right now,

it
is displaying the SaveAs dialog box and the user

manually
navigates to the location they want to save the file,

then
changes the saveAs file type box and clicks save.

Two questions:
1) Can I have the SaveAs dialog box default the SaveAs
file type to 'Excel Workbook'?

2) Can I have the whole SaveAs process happen without

the
dialog box popping up?


(I tried doing:

ThisWorkbook.SaveAs FileName:="Testing.xls"

but it saves the file that I have the macro in, not the
text file that was imported.)

Any help would be much appreciated,

Trevor



.


sbell

Saving text file in excel format through macro...
 
Trevor,

Yep - took me awhile to learn that ThisWorkBook is where the code resides
and ActiveWorkbook is any workbook that is currently active.

--
steveb
(Remove 'NoSpam' from email address if replying direct)
wrote in message
...
Steve,

I am much appreciative for your help. Who
knew "ActiveWorkbook" would be so different
from "ThisWorkbook"?

Thanks Again,

Trevor

-----Original Message-----
Trevor,

This works where FN = path and name of the file

'''''''''''''''''''''''''''''''''''''''''''''
ActiveWorkbook.SaveAs Filename:=FN & "xls", _
FileFormat:=xlNormal, Password:="",

WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
'''''''''''''''''''''''''''''''''''''''''''''
steve

"Trevor" wrote in

message
...
Hello All,

I am using a macro that imports a text file, manipulates
it and then saves it as an excel workbook. Right now,

it
is displaying the SaveAs dialog box and the user

manually
navigates to the location they want to save the file,

then
changes the saveAs file type box and clicks save.

Two questions:
1) Can I have the SaveAs dialog box default the SaveAs
file type to 'Excel Workbook'?

2) Can I have the whole SaveAs process happen without

the
dialog box popping up?


(I tried doing:

ThisWorkbook.SaveAs FileName:="Testing.xls"

but it saves the file that I have the macro in, not the
text file that was imported.)

Any help would be much appreciated,

Trevor



.





All times are GMT +1. The time now is 12:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com