Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Saving two file names? One with no extension?
I am having some dificulty finding the error in my code below. I can create
the file name I wish, except, I create second file name with no extension AND (you knew there was more, go ahead say it) the file name I want is like this example. "Original_filename.xlsNew_filename.xls" I do not know how to get rid of the duplicate file and the "xls" extension for the Original file name. My code: ' Macro recorded 4/20/2005 by RStanich ' Dim sPath As String, sNewFile As String Dim vMyFileName As Variant Dim sStartingName As String Sheets("Sheet2").Select Application.Run "CheckForOpenFile" Application.Run "ToggleControlChartBar" 'Get Current File Name 'Create File name Application.DisplayAlerts = False Range("C7").Select ActiveCell.FormulaR1C1 = "=R[-5]C& ""-"" &R[-5]C[1]" sPath = "c:\Modern_Excel_FIRs\" sFileName = ActiveCell vMyFileName = ActiveWorkbook.Name sNewFile = sPath & vMyFileName & "_" & sFileName & ".xls" Application.StatusBar = "Saving New FIR File" Sheets("Sheet1").Select Sheets("Sheet1").Copy ActiveWorkbook.SaveCopyAs sNewFile If sNewFile < "False" Then ActiveWorkbook.SaveAs sNewFile End If ActiveWorkbook.Close sNewFile Sheets("Sheet2").Select Application.DisplayAlerts = True Application.Run "ToggleControlChartBar" Application.StatusBar = " Ready " End Sub As always, your help is greatly appreciated. Best regards Rick S. PHX AZ |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Seeing Text File Names when Saving Excel Files | New Users to Excel | |||
Seeing existing file names when saving | Excel Discussion (Misc queries) | |||
Saving CSV file with TXT extension | Excel Discussion (Misc queries) | |||
Saving file names in a different color | Excel Discussion (Misc queries) | |||
Saving file names in a different color | Excel Discussion (Misc queries) |