Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default save existing file name, different format.

Hi all.
I've modified an existing macro, and want to do a save as.
1- I need to keep the same name.
I.e., if the existing file name is John, I'll be chaning it from
John.xls, or John.xlsm, to John.xlsx.

2- I'll be saving the file with the xlsx format.

Below is the code I'm using, after calling to another macro.
-------------------------------------------------------------------------
Sub SampleTest1()

Dim sFileNm As String

Application.Run "PERSONAL.XLSB!CompactAllSheets"
ChDir "S:\Assignments - Final\Truckee River Claims\BloatReducedFiles"
sFileNm = Application.InputBox(Prompt:="What's the name of the file?",
Type:=2)

ActiveWorkbook.SaveAs Filename:= _
"S:\Assignments - Final\Truckee River Claims\BloatReducedFiles\" &
sFileNm & ".xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
End Sub
---------------------------------------------------------------------

I'd prefer to bypass the inputbox, and just save whatever the existing file
name is-- I'm modifying the file, and saving the new version one folder
deeper into my directory structure.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default save existing file name, different format.

Sub test()
Folder = ActiveWorkbook.Path
FName = ActiveWorkbook.Name
'remove extension
FName = Left(FName, InStr(FName, ".") - 1)
SaveName = Folder & "\" & FName & ".xlsx"
ActiveWorkbook.SaveAs Filename:= _
FName, _
FileFormat:=xlOpenXMLWorkbook

End Sub

"SteveDB1" wrote:

Hi all.
I've modified an existing macro, and want to do a save as.
1- I need to keep the same name.
I.e., if the existing file name is John, I'll be chaning it from
John.xls, or John.xlsm, to John.xlsx.

2- I'll be saving the file with the xlsx format.

Below is the code I'm using, after calling to another macro.
-------------------------------------------------------------------------
Sub SampleTest1()

Dim sFileNm As String

Application.Run "PERSONAL.XLSB!CompactAllSheets"
ChDir "S:\Assignments - Final\Truckee River Claims\BloatReducedFiles"
sFileNm = Application.InputBox(Prompt:="What's the name of the file?",
Type:=2)

ActiveWorkbook.SaveAs Filename:= _
"S:\Assignments - Final\Truckee River Claims\BloatReducedFiles\" &
sFileNm & ".xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
End Sub
---------------------------------------------------------------------

I'd prefer to bypass the inputbox, and just save whatever the existing file
name is-- I'm modifying the file, and saving the new version one folder
deeper into my directory structure.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default save existing file name, different format.

Joel, are you sure about that last line of code? Should that be FName or
SaveName?

"Joel" wrote:

Sub test()
Folder = ActiveWorkbook.Path
FName = ActiveWorkbook.Name
'remove extension
FName = Left(FName, InStr(FName, ".") - 1)
SaveName = Folder & "\" & FName & ".xlsx"
ActiveWorkbook.SaveAs Filename:= _
FName, _
FileFormat:=xlOpenXMLWorkbook

End Sub

"SteveDB1" wrote:

Hi all.
I've modified an existing macro, and want to do a save as.
1- I need to keep the same name.
I.e., if the existing file name is John, I'll be chaning it from
John.xls, or John.xlsm, to John.xlsx.

2- I'll be saving the file with the xlsx format.

Below is the code I'm using, after calling to another macro.
-------------------------------------------------------------------------
Sub SampleTest1()

Dim sFileNm As String

Application.Run "PERSONAL.XLSB!CompactAllSheets"
ChDir "S:\Assignments - Final\Truckee River Claims\BloatReducedFiles"
sFileNm = Application.InputBox(Prompt:="What's the name of the file?",
Type:=2)

ActiveWorkbook.SaveAs Filename:= _
"S:\Assignments - Final\Truckee River Claims\BloatReducedFiles\" &
sFileNm & ".xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
End Sub
---------------------------------------------------------------------

I'd prefer to bypass the inputbox, and just save whatever the existing file
name is-- I'm modifying the file, and saving the new version one folder
deeper into my directory structure.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to save a file and overwrite existing file Daniel M Excel Programming 1 January 18th 08 07:45 PM
Save as new file ONLY and do not save changes to existing xls Sin Excel Programming 0 July 31st 07 12:30 AM
Force Save over existing file XCESIV[_18_] Excel Programming 3 May 25th 06 08:51 AM
can i save an existing .xls file as a .csv file using command line craigkan Excel Discussion (Misc queries) 2 February 18th 05 02:01 PM
get path - save new file - same sub-directory as existing file tegger Excel Programming 2 October 21st 03 10:45 AM


All times are GMT +1. The time now is 06:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"