Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I have 2 questions: I have an excel worksheet with 4 sections. I get my data from 4 users. I created 4 files (one file for user). Each file contains user's section. My problem is that I update my worksheet frequently and I want to automate the creation of users files. How can I do it using VBA ? 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 ? Thank you Gil D. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
Thank you for your help. One more problem: Function BackUp(...) causes run time error 70 on: FileCopy srcFolder & "\" & objF1.Name, DestFolder & "\" & objF1.Name It creates destination folder but does not copy files from source folder into it.. How can I solve this ? Function createXL() works great. Thank you for your help. Gil D. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
the files that you will going to backUp is opened, that's why it has
a runtime error. Close first all the files in that folder and run again the BackUp function. HTH |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
Thank you for your answer. I want that my user will be able to backup my application within excel (My application is an excel file). I understand (from your answer) that it is not possible. Should I create another excel workbook with backup function in order to do this ? Thank you Gil D. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No need to create another xls.
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 If objF1.Name < ThisWorkbook.Name Then FileCopy srcFolder & "\" & objF1.Name, DestFolder & "\" & objF1.Name Else ThisWorkbook.SaveAs DestFolder & "\" & ThisWorkbook.Name End If Next End Function |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No need to create another xls.
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 if objF1.Name < ThisWorkbook.Name then FileCopy srcFolder & "\" & objF1.Name, DestFolder & "\" & objF1.Name else ThisWorkbook.SaveAs DestFolder & "\" & ThisWorkbook.Name End if Next End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Create an automatic backup file on open in EXCEL? | Excel Discussion (Misc queries) | |||
Set Excel 2000 to automatically create backup file. | Excel Discussion (Misc queries) | |||
In Excel, I want to create a backup copy whenever I save a file. | Excel Discussion (Misc queries) | |||
create a separate backup file in excel when exiting | Excel Worksheet Functions | |||
How do I Create backup of excel file in other folder | Excel Discussion (Misc queries) |