Create new excel files, Save backup of excel file
I want to backup my excel file (and all the files within its directory)
to a new folder.
How can I do this using VBA ?
Function BackUp(srcFolder As String, DestFolder As String, createFolder
As Boolean)
Dim objFS As Object, objFolder As Object
Dim objFiles As Object, objF1 As Object
Dim strFolderPath As String
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(srcFolder)
Set objFiles = objFolder.Files
If createFolder Then
objFS.createFolder DestFolder
End If
For Each objF1 In objFiles
FileCopy srcFolder & "\" & objF1.Name, DestFolder & "\" &
objF1.Name
Next
End Function
I want to
automate the creation of users files. How can I do it using VBA ?
Function createXL()
Dim appXL As Object
Dim wrkBuk As Object
Set appXL = CreateObject("Excel.Application")
appXL.Visible = True
Set wrkBuk = appXL.Workbooks.Add
appXL.Cells(1,1).Value = Sheets("Sheet1").Cells(1,1).Value
wrkBuk.Saveas "C:\NewBuk.xls"
wrkBuk.Close
Set appXL = nothing
End Function
Hope this will help.
|