Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default code to save the whole folder in which is the workbook

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default code to save the whole folder in which is the workbook


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default code to save the whole folder in which is the workbook

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default code to save the whole folder in which is the workbook

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   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default code to save the whole folder in which is the workbook



Thankyou Dave !!!
As always helpful answer from you.



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
Force a Readonly Workbook to save to a different folder Charlotte Howard Excel Discussion (Misc queries) 6 August 23rd 06 04:41 PM
save workbook created from templete to a specific folder imh Excel Discussion (Misc queries) 1 June 2nd 06 11:29 PM
Need code to save file to new folder, erase from old folder Ron M. Excel Discussion (Misc queries) 1 February 24th 06 06:02 PM
Save Workbook without VBA code Ken Loomis Excel Programming 4 March 24th 05 11:38 PM
prevent user from saving file to a folder but allow my code to save from behind. susie Excel Programming 3 July 25th 03 03:01 PM


All times are GMT +1. The time now is 11:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"