none
How do I add the extension .zip to Excel or Word file

    Question

  • Hello all, can you please help me to add a .zip extension to an Excel or Word file. Thanks

    Thanks to all that continue to serve as help HashMan

    Monday, December 31, 2012 8:05 PM

Answers

  • Hi HashMan19_11,

    Thank you for posting in the MSDN Forum.

    Is this thread about step7. or step 8. in Customizing Excel Ribbon?

    If yes, you'll only need to rename the file as I've shown you in that thread.

    If you feel Rich's replies are helpful for you to solve your problems, you can pick out the most useful ones and mark it/them as answer.

    Thank you very much.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by HashMan19_11 Saturday, January 05, 2013 8:10 PM
    Friday, January 04, 2013 2:18 PM

All replies

  • Hello Hashman:

    When you create an xlsx file, it is already in a zipped format.  If you just rename the file from xlsx to zip, you can open it with a standard zip program (i.e. winzip).  There isn't an option that I could find within Excel 2010 to save it with the zip extension, but one thing you could do in VBA would  be to use the Workbook "After Save" event to use the VBA file handling procedures to rename a file.  Just rename the filename with a zip extension.

    Regards,


    Rich Locus, Logicwurks, LLC

    http://www.logicwurks.com


    • Edited by RichLocus Monday, December 31, 2012 9:07 PM
    Monday, December 31, 2012 9:01 PM
  • Hashman:

    For example, when you save a file from Excel, you know the path and filename that you saved.  Just use that path and filename and call the following routine which will rename the file with name and extension that you want:

    Public Function CopyFile(SourceFile As String, _
            TargetFile As String) As Boolean
    ' *********************************************************************************************
    ' * COPY A SOURCE FILE TO A TARGET FILE (OVERLAY TARGET IF PRESENT)                           *
    ' *********************************************************************************************
    
    ' *****************************************************************
    ' * (1) This function will copy a file from the SourceFile        *
    ' *     to the TargetFile - It will delete the TargetFile         *
    ' *                         if it already exists                  *
    ' * (2) You can rename the file as you copy it                    *
    ' * (3) A full path to both source and target is recommended      *
    ' * (4) If you omit the target path, the SourceFile is copied     *
    ' *     to The CurDir (Access Current Directory)                  *
    ' * (5) If you omit the source path, Access looks in the CurDir   *
    ' *     for the SourceFile                                        *
    ' *****************************************************************
    On Error GoTo err_In_Copy
        
      FileCopy SourceFile, TargetFile
      CopyFile = True
      
    mod_ExitFunction:
      Exit Function
      
    ' ***************************************************
    ' * Error Correction Routines                       *
    ' ***************************************************
    err_In_Copy:
      CopyFile = False
      Resume mod_ExitFunction
      
    End Function

    Regards,


    Rich Locus, Logicwurks, LLC

    http://www.logicwurks.com

    Monday, December 31, 2012 9:05 PM
  • Hello Rich Locus I am Trying to accomplish a task on th help system in the VBE. Object Library Reference for 2010. How do I ....     How to: Customize the Office Fluent Ribbon by Using an Open XML Formats File. Particularly step 7 and onwards.


    Thanks to all that continue to serve as help HashMan

    Tuesday, January 01, 2013 1:06 AM
  • Hashman:

    The above approach didn't work because Excel has it locked.  So, I tried and tested this method in the Workbook AfterSave Event.  It worked well for me and it saves an xlsm version and a zip version.

    Option Explicit
    
    Private Sub Workbook_AfterSave(ByVal Success As Boolean)
    ' ************************************************************
    ' Create a version of the file with a .zip file
    ' ************************************************************
    Dim strOriginalName As String
    Dim strNewName As String
    Dim wkbThisWorkbook As Workbook
    
    Set wkbThisWorkbook = ThisWorkbook
    
    strOriginalName = ActiveWorkbook.FullName
    strNewName = Left(strOriginalName, InStrRev(strOriginalName, ".")) & "zip"
    On Error GoTo CopyError
    wkbThisWorkbook.SaveCopyAs (strNewName)
    On Error GoTo 0
    Exit Sub
    
    CopyError:
    MsgBox ("File Did Not Save As A Zip")
    
    End Sub

    Regards,


    Rich Locus, Logicwurks, LLC

    http://www.logicwurks.com


    Tuesday, January 01, 2013 1:38 AM
  • Thanks Rich Locus. You are invaluable.


    Thanks to all that continue to serve as help HashMan

    Tuesday, January 01, 2013 3:39 AM
  • Hello Rich Locus and all, I have have got stuck on another step. I added the relationship tag on the _rels folder and dragged to the Ribbon customization folder but instead of replacing the old _rels file it gave me this message. This folder already contains a folder named '_rels'. Rename the folder you are trying to copy and then perform the operation again. I am unable to decide what to do? Can I please have help.

    Thanks to all that continue to serve as help HashMan

    Tuesday, January 01, 2013 7:15 PM
  • Hello Hashman:

    Since your last question is new and not directly related to the question I answered, could you post it as a new question?

    Regards,


    Rich Locus, Logicwurks, LLC

    http://www.logicwurks.com

    Wednesday, January 02, 2013 1:23 AM
  • Thanks Rich Locus, Happy New Year. Your answer fit within one of the steps, zipping the Excel file. I would like to learn how to unzip the Excel files back to .xlsm

    Thanks to all that continue to serve as help HashMan

    Thursday, January 03, 2013 1:07 AM
  • Hello Hashman:

    Let's say that you created the "zip" file from Excel in the method I showed above.  All you have to do is rename it from Windows Explorer or a Script.

    For example, from Excel, let's say you created this file:

    CorporateLedger.zip.

    To change it back to a form that Excel can open, all you have to do is rename it to:

    CorporateLedger.xlsm

    In other words, an Excel file is really just a zipped file with a different extension.

    Hope that helps.

    Regards,


    Rich Locus, Logicwurks, LLC

    http://www.logicwurks.com


    • Edited by RichLocus Thursday, January 03, 2013 4:23 AM
    Thursday, January 03, 2013 4:23 AM
  • Hi HashMan19_11,

    Thank you for posting in the MSDN Forum.

    Is this thread about step7. or step 8. in Customizing Excel Ribbon?

    If yes, you'll only need to rename the file as I've shown you in that thread.

    If you feel Rich's replies are helpful for you to solve your problems, you can pick out the most useful ones and mark it/them as answer.

    Thank you very much.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by HashMan19_11 Saturday, January 05, 2013 8:10 PM
    Friday, January 04, 2013 2:18 PM