Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Saving filename same as import filename
I have a macro that imports a txt file(test.txt) into an Excel spreadsheet and then I want to save this file with the same name as the txt file(test) obviously w/out the .txt. Any ideas? Thanks. Matt
|
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Saving filename same as import filename
Activeworkbook.SaveAs Activeworkbook.Path & "\" & _
left(Activeworkbook.Filename, len(Activeworkbook.Filename)-4) & ".xls", _ fileformat:=xlWorkbookNormal -- Regards, Tom Ogilvy "Matt" wrote in message ... I have a macro that imports a txt file(test.txt) into an Excel spreadsheet and then I want to save this file with the same name as the txt file(test) obviously w/out the .txt. Any ideas? Thanks. Matt |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Saving filename same as import filename
-----Original Message----- I have a macro that imports a txt file(test.txt) into an Excel spreadsheet and then I want to save this file with the same name as the txt file(test) obviously w/out the .txt. Any ideas? Thanks. Matt . Dim MyFileName As String MyFileName = "Your Text File Name" 'use the following name (using the appropriate code) 'to import text file MyFileName & ."txt" ActiveWorkbook.SaveAs FileName:="C:\" & MyFileName & ".xls", FileFormat:= _ xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _ , CreateBackup:=False |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Saving filename same as import filename
-----Original Message----- -----Original Message----- I have a macro that imports a txt file(test.txt) into an Excel spreadsheet and then I want to save this file with the same name as the txt file(test) obviously w/out the .txt. Any ideas? Thanks. Matt . Dim MyFileName As String MyFileName = "Your Text File Name" 'use the following name (using the appropriate code) 'to import text file MyFileName & ."txt" ActiveWorkbook.SaveAs FileName:="C:\" & MyFileName & ".xls", FileFormat:= _ xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _ , CreateBackup:=False . Whoops that should be MyFileName & ".txt" Sorry about that.. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Saving filename same as import filename
I tried this code but I get an error that says Method 'SaveAs' of object '_Workbook' failed. I can't figure out what the problem is other than maybe it is naming the excel workbook the same as the text file it is importing. For example it is naming it test.txt.xls. Could this be a problem? fileToOpen is the name of the text file that I am importing. Thanks. Mat
ActiveWorkbook.SaveAs Filename:="H:\" & fileToOpen & ".xls", FileFormat:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Saving file using value in cell as the filename | Excel Worksheet Functions | |||
Saving XLS workbook with set filename | Excel Discussion (Misc queries) | |||
set filename to <filename-date on open | Excel Worksheet Functions | |||
Filename import | Excel Discussion (Misc queries) | |||
Saving Cell value as filename | Excel Programming |