SaveAs to a different folder

C

C C

Hello.

I need a few lines of codes to add to my macro which
can do the following:

Save an ActiveDocument.Name to a different
folder from where the worksheet is read from
in Excel Format.

You see, I open a comma delimited text file
in Excel. I already have the macro to format
the columns the way I want, insert a few formulas
and I want to save the Excel Worksheet with
the same root name with the .xls extension
and as an Excel format.

Thanks in advance.
 
D

Dave Peterson

Dim myFileName as string

myFilename = "C:\temp\ & _
left(activeworkbook.name,len(activeworkbook.name)-4) & ".xls"

activeworkbook.saveas filename:=myfilename, fileformat:=xlworkbooknormal

This assumes that the last four characters of the activeworkbook's name is the
extension (like .csv).

Change C:\temp\
to the folder you want.
 
Top