Advertisement
| 09.29.2008 at 08:44PM PDT, ID: 23773629 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: |
Sub Zip_ThisWorkbook()
Dim strDate As String, StrDateBUpFolder As String, DefPath As String, DefPathBackup As String
Dim FileNameOriginZip, FileNameXls, FileNameDestinationZip, FileNameBUp
Dim oApp As Object
Application.DisplayStatusBar = True 'turns on the status bar
Application.StatusBar = "Please wait while File is Saved and Zipped" ' displays a message in Status Bar
Application.ScreenUpdating = False ' Hides changes to screen until Macro finished
'Define This workbook Path and Backup Folder date to use
DefPath = ThisWorkbook.Path & "\"
StrDateBUpFolder = Format(Now, "mmmyyyy")
'Checks to See If A Directory Exists, If Not, Creates It
DefPathBackup = ThisWorkbook.Path & "\" & "Enrol Backup" & StrDateBUpFolder & "\"
DirTest = Dir$(DefPathBackup, vbDirectory)
If DirTest = "" Then
MkDir DefPathBackup
DoEvents 'just to make sure it is there
End If
'Create date/time string and the temporary xls and zip file name
strDate = Format(Now, " (ddd dmmmyy hmmam/pmss") & "sec)"
FileNameBUp = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4) & strDate & ".zip"
FileNameDestinationZip = DefPathBackup & FileNameBUp 'Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4) & strDate & ".zip"
FileNameOriginZip = DefPath & FileNameBUp 'Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4) & strDate & ".zip"
FileNameXls = DefPath & ThisWorkbook.Name
If Dir(FileNameOriginZip) = "" Then ' And Dir(FileNameXls) = "" Then
'Make copy of the Thisworkbook
ThisWorkbook.Save
'Create empty Zip File
Application.ScreenUpdating = False ' Hides changes to screen until Macro finished
NewZip (FileNameOriginZip)
'Copy the file in the compressed folder
Set oApp = CreateObject("Shell.Application")
oApp.Namespace(FileNameOriginZip).CopyHere FileNameXls
'Keep script waiting until Compressing is done
On Error Resume Next
Do Until oApp.Namespace(FileNameOriginZip).items.Count = 1
Application.Wait (Now + TimeValue("0:00:01"))
Loop
On Error GoTo 0
' Move Zipped file to Backup Directory
Name FileNameOriginZip As FileNameDestinationZip
Else
End If
MsgBox "This file has been Saved and Zipped - Om Tat Sat"
Application.StatusBar = False 'turns off Message
Application.ScreenUpdating = True ' Turns back on screen updating
End Sub
Sub NewZip(sPath)
'Create empty Zip File
'Changed by keepITcool Dec-12-2005
If Len(Dir(sPath)) > 0 Then Kill sPath
Open sPath For Output As #1
Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)
Close #1
End Sub
|
Advertisement