اذهب الي المحتوي
أوفيسنا

الردود الموصى بها

قام بنشر

السلام عليكم

هذا ملف من اعداد الأستاذ الكبير عادل حنفى

يقوم بعمل نسخة احتياطية عند غلق الملف ولكنها مضغوطة كما تريد

 

backup.zip

قام بنشر

السلام عليكم و رحمة الله و بركاته
الاخ الفاضل الاستاذ / رجب جاويش

جزاك الله كل خير .. ملف ممتاز

والشكر موصول للاخ الاستاذ الكبير / عادل حنفي
و الله المستعان
و السلام عليكم و رحمة الله و بركاته

قام بنشر

مكانة مظبوط تماما ولكنة يتعارض مع كود اخر في حدث الملف

Private Sub Workbook_BeforeClose(Cancel As Boolean)

يوجد كودين بهذا الاسم

فهل لابد ان اغير الاسم وهذة تكون المشكلة

قام بنشر

السلام عليكم ورحمة الله وبركاته

الاستاذ الحبيب رجب جاويش اعطاك الله سبحانه وتعالى الصحة والعافية

كود رائع وعمل اروع والشكر موصول للاستاذ الفاضل عادل حنفي جزاه الله خيرا

دمتم في رعاية الله وحفظه

قام بنشر

اخي رجب

تفضل

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("main screen").Activate
Application.ScreenUpdating = False
For I = 2 To Sheets.Count
Sheets(I).Unprotect (1234)
Next
Application.ScreenUpdating = True
End Sub
Private Sub Workbook_Open()
Sheets("MyDate").Range("E3:IT3").ClearContents
For I = 2 To Sheets.Count
Sheets("MyDate").Cells(3, I + 3) = Sheets(I).Name
Next
'UserForm1.Show
End Sub

قام بنشر

أخى وليد

تم دمج الأكواد المطلوبة

وتكون بهذا الشكل

Private Sub Workbook_BeforeClose(Cancel As Boolean)
  Dim strDate As String, DefPath As String
    Dim FileNameZip, FileNameXls
    Dim oApp As Object
    Sheets("main screen").Activate
For I = 2 To Sheets.Count
Sheets(I).Unprotect (1234)
Next
     If ActiveWorkbook Is Nothing Then Exit Sub
    DefPath = ActiveWorkbook.Path
    If Len(DefPath) = 0 Then
        MsgBox "Plz Save activeworkbook before zipping" & Space(12), vbInformation, "zipping"
        Exit Sub
    End If
    If Right(DefPath, 1) <> "\" Then
        DefPath = DefPath & "\"
    End If
    strDate = Format(Now, " dd-mmm-yy h-mm-ss")
    FileNameZip = DefPath & Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) & strDate & ".zip"
    FileNameXls = DefPath & Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) & strDate & ".xls"
 
    If Dir(FileNameZip) = "" And Dir(FileNameXls) = "" Then
        ActiveWorkbook.SaveCopyAs FileNameXls
        newzip (FileNameZip)
        Set oApp = CreateObject("Shell.Application")
        oApp.Namespace(FileNameZip).CopyHere FileNameXls
        On Error Resume Next
        Do Until oApp.Namespace(FileNameZip).items.Count = 1
            Application.Wait (Now + TimeValue("0:00:01"))
        Loop
        On Error GoTo 0
        Kill FileNameXls
        MsgBox "completed zipped : " & vbNewLine & FileNameZip, vbInformation, "zipping"
    Else
        MsgBox "FileNameZip or/and FileNameXls exist", vbInformation, "zipping"

    End If
End Sub

Private Sub Workbook_Open()
Sheets("MyDate").Range("E3:IT3").ClearContents
For I = 2 To Sheets.Count
Sheets("MyDate").Cells(3, I + 3) = Sheets(I).Name
Next
'UserForm1.Show
End Sub

Private Sub newzip(sPath)
    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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information