Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Is it possible for a macro to save a workbook in a new location and delete
the old location |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
maybe this simple idea will help?
Sub movefile() OldName = "C:\oldfolder\oldname.xls" NewName = "C:\newfolder\newname.xls" Name OldName As NewName End Sub -- Don Guillett SalesAid Software "Sadcrab" wrote in message ... Is it possible for a macro to save a workbook in a new location and delete the old location |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() "Don Guillett" wrote: maybe this simple idea will help? Sub movefile() OldName = "C:\oldfolder\oldname.xls" NewName = "C:\newfolder\newname.xls" Name OldName As NewName End Sub -- Thanks Don but I can't get it to work. I get a runtime error 53 File not found more help on this please. Thanks |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I think Don was just showing a sample so you could see how to use the Name
statement. If you want to save an open workbook as a new name and then delete the original workbook, you could do something like this (with absolutely no checks at all!): Option Explicit Sub testme() Dim OldName As String Dim NewName As String NewName = "C:\changethistowhatyouneed\filename.xls" With ActiveWorkbook 'or ThisWorkbook???? OldName = .FullName .SaveAs Filename:=NewName, FileFormat:=xlWorkbookNormal End With Kill OldName End Sub Sadcrab wrote: "Don Guillett" wrote: maybe this simple idea will help? Sub movefile() OldName = "C:\oldfolder\oldname.xls" NewName = "C:\newfolder\newname.xls" Name OldName As NewName End Sub -- Thanks Don but I can't get it to work. I get a runtime error 53 File not found more help on this please. Thanks -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thanks Dave,
What I would like to do is save the same workbook (with different data) several times giving a new name to each saved workbook when moved. At the moment using this macro will overwrite the last saved workbook and not give me an option to save as and give a different name. "Dave Peterson" wrote: I think Don was just showing a sample so you could see how to use the Name statement. If you want to save an open workbook as a new name and then delete the original workbook, you could do something like this (with absolutely no checks at all!): Option Explicit Sub testme() Dim OldName As String Dim NewName As String NewName = "C:\changethistowhatyouneed\filename.xls" With ActiveWorkbook 'or ThisWorkbook???? OldName = .FullName .SaveAs Filename:=NewName, FileFormat:=xlWorkbookNormal End With Kill OldName End Sub Sadcrab wrote: "Don Guillett" wrote: maybe this simple idea will help? Sub movefile() OldName = "C:\oldfolder\oldname.xls" NewName = "C:\newfolder\newname.xls" Name OldName As NewName End Sub -- Thanks Don but I can't get it to work. I get a runtime error 53 File not found more help on this please. Thanks -- Dave Peterson |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Dim NewName as string
dim NewNamePfx as string dim iCtr as long newnamePfx = "C:\whateveryouwant\filename" in some kind of loop for ictr = 1 to 100 newname = newnamepfx & format(now, "yyyymmdd_hhmmss") & ".xls" activeworkbook.savecopyas newname next ictr This saves 100 copies and includes the date/time in the filename. Sadcrab wrote: Thanks Dave, What I would like to do is save the same workbook (with different data) several times giving a new name to each saved workbook when moved. At the moment using this macro will overwrite the last saved workbook and not give me an option to save as and give a different name. "Dave Peterson" wrote: I think Don was just showing a sample so you could see how to use the Name statement. If you want to save an open workbook as a new name and then delete the original workbook, you could do something like this (with absolutely no checks at all!): Option Explicit Sub testme() Dim OldName As String Dim NewName As String NewName = "C:\changethistowhatyouneed\filename.xls" With ActiveWorkbook 'or ThisWorkbook???? OldName = .FullName .SaveAs Filename:=NewName, FileFormat:=xlWorkbookNormal End With Kill OldName End Sub Sadcrab wrote: "Don Guillett" wrote: maybe this simple idea will help? Sub movefile() OldName = "C:\oldfolder\oldname.xls" NewName = "C:\newfolder\newname.xls" Name OldName As NewName End Sub -- Thanks Don but I can't get it to work. I get a runtime error 53 File not found more help on this please. Thanks -- Dave Peterson -- Dave Peterson |
#7
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
This does work. Just change oldfolder to your desired folder and oldname to
your file name, etc. Then fire. -- Don Guillett SalesAid Software "Sadcrab" wrote in message ... "Don Guillett" wrote: maybe this simple idea will help? Sub movefile() OldName = "C:\oldfolder\oldname.xls" NewName = "C:\newfolder\newname.xls" Name OldName As NewName End Sub -- Thanks Don but I can't get it to work. I get a runtime error 53 File not found more help on this please. Thanks |
#8
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Sorry Don I still can't get it to work can you supply an example
"Don Guillett" wrote: This does work. Just change oldfolder to your desired folder and oldname to your file name, etc. Then fire. -- Don Guillett SalesAid Software "Sadcrab" wrote in message ... "Don Guillett" wrote: maybe this simple idea will help? Sub movefile() OldName = "C:\oldfolder\oldname.xls" NewName = "C:\newfolder\newname.xls" Name OldName As NewName End Sub -- Thanks Don but I can't get it to work. I get a runtime error 53 File not found more help on this please. Thanks |
#10
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Don
I've changed the info as follows and created relevant directories: Sub movefile() OldName = "C:\Test\Active\Test1.xls" NewName = "C:\Test\Complete\Test1.xls" Name OldName As NewName End Sub "Don Guillett" wrote: I did provide an example. Perhaps you could give the info on the path and file name for old and new?? -- Don Guillett SalesAid Software "Sadcrab" wrote in message ... Sorry Don I still can't get it to work can you supply an example "Don Guillett" wrote: This does work. Just change oldfolder to your desired folder and oldname to your file name, etc. Then fire. -- Don Guillett SalesAid Software "Sadcrab" wrote in message ... "Don Guillett" wrote: maybe this simple idea will help? Sub movefile() OldName = "C:\oldfolder\oldname.xls" NewName = "C:\newfolder\newname.xls" Name OldName As NewName End Sub -- Thanks Don but I can't get it to work. I get a runtime error 53 File not found more help on this please. Thanks |
#11
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
And it didn't work??? I just created the same folders and file and moved it
with the macro. -- Don Guillett SalesAid Software "Sadcrab" wrote in message ... Don I've changed the info as follows and created relevant directories: Sub movefile() OldName = "C:\Test\Active\Test1.xls" NewName = "C:\Test\Complete\Test1.xls" Name OldName As NewName End Sub "Don Guillett" wrote: I did provide an example. Perhaps you could give the info on the path and file name for old and new?? -- Don Guillett SalesAid Software "Sadcrab" wrote in message ... Sorry Don I still can't get it to work can you supply an example "Don Guillett" wrote: This does work. Just change oldfolder to your desired folder and oldname to your file name, etc. Then fire. -- Don Guillett SalesAid Software "Sadcrab" wrote in message ... "Don Guillett" wrote: maybe this simple idea will help? Sub movefile() OldName = "C:\oldfolder\oldname.xls" NewName = "C:\newfolder\newname.xls" Name OldName As NewName End Sub -- Thanks Don but I can't get it to work. I get a runtime error 53 File not found more help on this please. Thanks |
#12
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() No message on screen as follows: Run-time error 75: Path/File Access error "Don Guillett" wrote: And it didn't work??? I just created the same folders and file and moved it with the macro. -- Don Guillett SalesAid Software "Sadcrab" wrote in message ... Don I've changed the info as follows and created relevant directories: Sub movefile() OldName = "C:\Test\Active\Test1.xls" NewName = "C:\Test\Complete\Test1.xls" Name OldName As NewName End Sub "Don Guillett" wrote: I did provide an example. Perhaps you could give the info on the path and file name for old and new?? -- Don Guillett SalesAid Software "Sadcrab" wrote in message ... Sorry Don I still can't get it to work can you supply an example "Don Guillett" wrote: This does work. Just change oldfolder to your desired folder and oldname to your file name, etc. Then fire. -- Don Guillett SalesAid Software "Sadcrab" wrote in message ... "Don Guillett" wrote: maybe this simple idea will help? Sub movefile() OldName = "C:\oldfolder\oldname.xls" NewName = "C:\newfolder\newname.xls" Name OldName As NewName End Sub -- Thanks Don but I can't get it to work. I get a runtime error 53 File not found more help on this please. Thanks |
#13
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() "Don Guillett" wrote: And it didn't work??? I just created the same folders and file and moved it with the macro. -- Don Guillett SalesAid Software "Sadcrab" wrote in message ... Don I've changed the info as follows and created relevant directories: Sub movefile() OldName = "C:\Test\Active\Test1.xls" NewName = "C:\Test\Complete\Test1.xls" Name OldName As NewName End Sub "Don Guillett" wrote: I did provide an example. Perhaps you could give the info on the path and file name for old and new?? -- Don Guillett SalesAid Software "Sadcrab" wrote in message ... Sorry Don I still can't get it to work can you supply an example "Don Guillett" wrote: This does work. Just change oldfolder to your desired folder and oldname to your file name, etc. Then fire. -- Don Guillett SalesAid Software "Sadcrab" wrote in message ... "Don Guillett" wrote: maybe this simple idea will help? Sub movefile() OldName = "C:\oldfolder\oldname.xls" NewName = "C:\newfolder\newname.xls" Name OldName As NewName End Sub -- Thanks Don but I can't get it to work. I get a runtime error 53 File not found more help on this please. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I delete a macro in Excel 2003? Button is greyed out. | Excel Discussion (Misc queries) | |||
error when running cut & paste macro | Excel Worksheet Functions | |||
Button assign macro breaks with file name change and appears elsew | Excel Discussion (Misc queries) | |||
Assigning macro to button | Excel Discussion (Misc queries) | |||
Copying a workbook with custom toolbar assigned to a macro | Excel Discussion (Misc queries) |