Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm trying to save a file with a macro. I have 90 different files that
I'm running the same macro on. When it's done I want the macro to save it but with a different name. Right now the code is setting the name of the file to the first name I put in (e.g. CMAC301). I want the next file to be named CMAC302. How do I do that? When I had Office 97, I was able to somehow pause the macro, input data as I needed and then resume. Is this still available? HELP!!!!!!!!!!!!!!!!!!!!!! ------------------------------------------------ Message posted from the Excel Tip Forum at http://www.ExcelTip.com/forum/ -- View and post usenet messages directly from http://www.ExcelTip.com -- Hundreds of free MS Excel tips, tricks and solutions ------------------------------------------------ |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() -----Original Message----- I'm trying to save a file with a macro. I have 90 different files that I'm running the same macro on. When it's done I want the macro to save it but with a different name. Right now the code is setting the name of the file to the first name I put in (e.g. CMAC301). I want the next file to be named CMAC302. How do I do that? When I had Office 97, I was able to somehow pause the macro, input data as I needed and then resume. Is this still available? HELP!!!!!!!!!!!!!!!!!!!!!! ------------------------------------------------ Message posted from the Excel Tip Forum at http://www.ExcelTip.com/forum/ -- View and post usenet messages directly from http://www.ExcelTip.com -- Hundreds of free MS Excel tips, tricks and solutions ------------------------------------------------ . Not sure if I quite follow what you need to do - see if this sounds useful.. If the files are created one at a time and you need to save each one as you go then you need a way to track the counter - here I've got a Workbook called Central where I input the "CMAC" text and the start of the count. Each time the macro is run the counter is advanced and the central worksheet is updated for next time. I'd put the macro code in this central workbook. dim wb as workbook dim wbCENTRAL as workbook Dim ws as worksheet dim strNAME as string dim intCOUNT as integer set wb = ActiveWorkbook set wbCENTRAL = Workbooks("CENTRAL.xls") set ws = wbcentral.activesheet strNAME = ws.cells(1,1).value '''Storage for "CMAC" intcount = ws.cells(1,2).value '''Storage for Counter wb.SaveAs("C:\My Documents\" & strname & intcount & ".xls") intCOUNT = intCOUNT+1 ws.cells(1,2).value = intcount '''Resets the counter for next time Cheers Matthew |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
two possibilities...
1) Sub SaveFileAs() Dim sFileName As String sFileName = Application.GetSaveAsFilename If sFileName = "False" Then Exit Sub ActiveWorkbook.SaveAs sFileName End Sub 2) Sub SaveFileAs() Dim sFileName As String sFileName = InputBox("Enter Name to be saved as...") If sFileName = "" Then Exit Sub ActiveWorkbook.SaveAs sFileName End Sub just a couple of ideas you could also add ActiveWorkbook.Close False before the End Dub to close the file after saving it. Patrick Molloy Microsoft Excel MVP -----Original Message----- I'm trying to save a file with a macro. I have 90 different files that I'm running the same macro on. When it's done I want the macro to save it but with a different name. Right now the code is setting the name of the file to the first name I put in (e.g. CMAC301). I want the next file to be named CMAC302. How do I do that? When I had Office 97, I was able to somehow pause the macro, input data as I needed and then resume. Is this still available? HELP!!!!!!!!!!!!!!!!!!!!!! ------------------------------------------------ Message posted from the Excel Tip Forum at http://www.ExcelTip.com/forum/ -- View and post usenet messages directly from http://www.ExcelTip.com -- Hundreds of free MS Excel tips, tricks and solutions ------------------------------------------------ . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
2007 Macro to Open File, Delete Contents, Save New File | Excel Discussion (Misc queries) | |||
Allow a macro to save over another file | Excel Discussion (Misc queries) | |||
Macro Save File (Unique file name) | Excel Worksheet Functions | |||
Macro to save a file as | Excel Discussion (Misc queries) | |||
Macro to save a file as a PDF | Excel Discussion (Misc queries) |