+ Reply to Thread
Results 1 to 2 of 2

VBA to save a file with a password

Hybrid View

Ang12345 VBA to save a file with a... 10-08-2010, 02:16 PM
TMS Re: VBA to save a file with a... 10-08-2010, 05:11 PM
  1. #1
    Registered User
    Join Date
    01-15-2010
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    29

    VBA to save a file with a password

    Hi Everyone,
    Can someone help me to add a password to save a file with. the code I have so far is as follows.

    It needs to be saved in this particular folder with a passowrd that I will specify. The password does not change so I have that as part of the macro. The file name can also be todaysfile

        
    ActiveWorkbook.SaveAs Filename:= _
            "Y:\filefolder11\filefolder2\filefolder3\Ifilefolder4\todaysfile.xlsx", FileFormat:= _
            xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,454

    Re: VBA to save a file with a password

    In the VBE, click in SaveAs and press F1 for the Help on the method.

    expression.SaveAs(FileName, FileFormat, Password, WriteResPassword, ReadOnlyRecommended, CreateBackup, AccessMode, ConflictResolution, AddToMru, TextCodepage, TextVisualLayout, Local)

    You need ... Password:="YourPassword"

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1