Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi All
Is it possible to change this code: Sub SaveBackup() ActiveWorkbook.SaveCopyAs "d:\MyBook.xls" End Sub to save a copy of the Folder in which is the Book-to back up not only €śMyBook€ť but the whole current folder with the book? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Yep. However, you're going to open up a whole can of worms such a traversing your directory tree, using fileobjects and it will not b easy -- Rich_ ----------------------------------------------------------------------- Rich_z's Profile: http://www.excelforum.com/member.php...fo&userid=2473 View this thread: http://www.excelforum.com/showthread.php?threadid=38347 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This will copy the folder.
Option Explicit Sub saveFolder() Dim FSO As Scripting.FileSystemObject Dim myFolder As Folder Dim myPath As String myPath = ActiveWorkbook.Path If myPath = "" Then MsgBox "please save this file first" Exit Sub End If Set FSO = New Scripting.FileSystemObject FSO.CopyFolder Source:=myPath, _ Destination:="c:\temp\backup", overwritefiles:=True End Sub But it doesn't do the workbook save. You may want to add that to start. (I wasn't sure.) Tim wrote: Hi All Is it possible to change this code: Sub SaveBackup() ActiveWorkbook.SaveCopyAs "d:\MyBook.xls" End Sub to save a copy of the Folder in which is the Book-to back up not only €śMyBook€ť but the whole current folder with the book? -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That original post needed a reference to "microsoft scripting runtime".
This version doesn't. Option Explicit Sub saveFolder() Dim FSO As Object Dim myFolder As Object Dim myPath As String myPath = ActiveWorkbook.Path If myPath = "" Then MsgBox "please save this file first" Exit Sub End If Set FSO = CreateObject("Scripting.FileSystemObject") FSO.CopyFolder Source:=myPath, _ Destination:="c:\temp\backup", overwritefiles:=True End Sub Tim wrote: Hi All Is it possible to change this code: Sub SaveBackup() ActiveWorkbook.SaveCopyAs "d:\MyBook.xls" End Sub to save a copy of the Folder in which is the Book-to back up not only €śMyBook€ť but the whole current folder with the book? -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Thankyou Dave !!! As always helpful answer from you. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Force a Readonly Workbook to save to a different folder | Excel Discussion (Misc queries) | |||
save workbook created from templete to a specific folder | Excel Discussion (Misc queries) | |||
Need code to save file to new folder, erase from old folder | Excel Discussion (Misc queries) | |||
Save Workbook without VBA code | Excel Programming | |||
prevent user from saving file to a folder but allow my code to save from behind. | Excel Programming |