Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default delete workbook from one location and save workbook to new locatio

I need to be able to save a workbook to a new location and delete the same
workbook from the old location, if not delete then move the file to another
folder.
I am able to save a file using a named range but with my code I can't seem
to be able to delete.
I am currently trying with the following code:

Sub DeletethenSaveFile()

Dim Range As String
Set Proj = Sheets("Form").Range("$F$10")
DeleteFile "Blah Blah Blah" & Range("Proj") & "2.xls"
MsgBox "The requested file has been deleted"
ThisWorkbook.SaveCopyAs "Blah Blah Blah" & Range("Proj") & "2.xls"
MsgBox "Your file has been saved to it's new location"

End Sub

Please help! D
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default delete workbook from one location and save workbook to new locatio

Hi Damien,
May be you can try this :
Sub DeletethenSaveFile()
Dim Range As String, Addr as string, Proj as string
Proj = Sheets("Form").Range("$F$10")
Addr = "Blah Blah Blah" & Range(Proj) & "2.xls"
MsgBox "The requested file has been deleted"
ThisWorkbook.SaveCopyAs "Blah Blah Blah" & Range("Proj") & "2.xls"
Kill Addr 'To kill or delete old file after copying it
MsgBox "Your file has been saved to it's new location"
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default delete workbook from one location and save workbook to new loc

Cheers, The Kill function works great, it also works with my code when I
knock out the Dim and Set and replace DeleteFile with Kill.

Kind Regards, D

" wrote:

Hi Damien,
May be you can try this :
Sub DeletethenSaveFile()
Dim Range As String, Addr as string, Proj as string
Proj = Sheets("Form").Range("$F$10")
Addr = "Blah Blah Blah" & Range(Proj) & "2.xls"
MsgBox "The requested file has been deleted"
ThisWorkbook.SaveCopyAs "Blah Blah Blah" & Range("Proj") & "2.xls"
Kill Addr 'To kill or delete old file after copying it
MsgBox "Your file has been saved to it's new location"
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default delete workbook from one location and save workbook to new loc

Hi Damien,
please note that Kill is not bring your file to Recycle bin, so you
can't restore them after Kill.

You can use API function call to send file to Recycle bin.

Thanks,

halim


Damien menuliskan:
Cheers, The Kill function works great, it also works with my code when I
knock out the Dim and Set and replace DeleteFile with Kill.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default delete workbook from one location and save workbook to new loc

Hi Halim,

Thanks a million, I need to delete permanently to stop multiple dupications
on our servers,

Kind Regards, D

" wrote:

Hi Damien,
please note that Kill is not bring your file to Recycle bin, so you
can't restore them after Kill.

You can use API function call to send file to Recycle bin.

Thanks,

halim


Damien menuliskan:
Cheers, The Kill function works great, it also works with my code when I
knock out the Dim and Set and replace DeleteFile with Kill.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default delete workbook from one location and save workbook to new locatio

Another option is to use the VBA name function
See
http://www.rondebruin.nl/folder.htm



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Damien" wrote in message ...
I need to be able to save a workbook to a new location and delete the same
workbook from the old location, if not delete then move the file to another
folder.
I am able to save a file using a named range but with my code I can't seem
to be able to delete.
I am currently trying with the following code:

Sub DeletethenSaveFile()

Dim Range As String
Set Proj = Sheets("Form").Range("$F$10")
DeleteFile "Blah Blah Blah" & Range("Proj") & "2.xls"
MsgBox "The requested file has been deleted"
ThisWorkbook.SaveCopyAs "Blah Blah Blah" & Range("Proj") & "2.xls"
MsgBox "Your file has been saved to it's new location"

End Sub

Please help! D



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
Feature to automatically save back up files to a different locatio geezz Excel Discussion (Misc queries) 2 December 23rd 08 12:37 PM
Select sheet tabs in workbook & save to separate workbook files stratocaster Excel Worksheet Functions 2 March 1st 06 03:35 PM
Automatically Delete WorkBook 2 modules by using Workbook 1 module ddiicc Excel Programming 5 July 27th 05 12:53 PM
Macro in Excel 2002 to save a workbook to a FTP location Lloyd Excel Discussion (Misc queries) 0 December 21st 04 02:49 PM
What commands do you use to name a workbook, save a workbook,open a workbook Steven R. Berke Excel Programming 1 July 24th 03 11:37 PM


All times are GMT +1. The time now is 06:36 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"