Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default Macro assigned to a button

Is it possible for a macro to save a workbook in a new location and delete
the old location
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Macro assigned to a button

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default Macro assigned to a button



"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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro assigned to a button

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default Macro assigned to a button

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro assigned to a button

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Macro assigned to a button

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default Macro assigned to a button

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default Macro assigned to a button

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
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 do I delete a macro in Excel 2003? Button is greyed out. mg Excel Discussion (Misc queries) 3 August 17th 06 12:23 AM
error when running cut & paste macro Otto Moehrbach Excel Worksheet Functions 4 August 9th 06 01:49 PM
Button assign macro breaks with file name change and appears elsew Student Excel Discussion (Misc queries) 2 July 25th 06 09:06 PM
Assigning macro to button d Excel Discussion (Misc queries) 0 August 22nd 05 01:40 PM
Copying a workbook with custom toolbar assigned to a macro Matt W Excel Discussion (Misc queries) 1 February 4th 05 10:46 PM


All times are GMT +1. The time now is 04:34 PM.

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"