View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
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