Saving text file in excel format through macro...

T

Trevor

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
 
S

sbell

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
 
G

Guest

Steve,

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

Thanks Again,

Trevor
 
S

sbell

Trevor,

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top