Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 24 of 24

Thread: Two questions re Template Password

  1. #21
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location
    Sorry for the delay in posting my code?I had to work on other things for awhile. Anyway, here?s the code as I revised it. I need to open a group of password protected files, but I don?t want to have to manually type in the password and unlock each one.

    I want to modify the code so that all the files in the folder will open, the password will be applied to unlock each one of them, and all files are on screen and ready for me to type in.

    [vba]Sub CheckMyDir()

    Dim path As String
    Dim strFile As String
    Dim getFile

    path = "C:\work\My Folder"
    getFile = Dir(path & "*.dot")

    Do While getFile <> ""
    strFile = path & getFile
    Documents.Open FileName:=strFile, passwordtemplate:="doccenter"
    getFile = Dir
    Loop

    End Sub[/vba]

    I'm totally sure it's me that's messed up the code!

  2. #22
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Like I said....you must have changed something incorrectly.

    You need a "\" on your path!! Look at the code I posted.

    path = "C:\work\My Folder\"

    Say getFile is "thisTemplate.dot", here is what Documents.Open is seeing:
    [vba]Documents.Open Filename:= "C:\work\My FolderthisTemplate.dot"[/vba]In other words, a file named My FolderthisTemplate.dot in the c:\work folder.

    BTW: I still think this is crazy crazy. WHY are you having all those files open??????? I am sorry, I just can not believe it is needed. I am not buying that anyone needs to have the number of files open you seem to be talking about.

    Could you please tell me why you need to open all those files. Not that that you need to open them, and do stuff. That I can understand. But why you need to have them STAY open.
    and all files are on screen and ready for me to type in
    What on earth could possible require this????? Especially if they really ARE template files.

    Something not right here Cheryl.

  3. #23
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location
    I would like to have these combined into fewer files, but the people requesting these templates do NOT want that. So, I need to work with what I have.

    They also recently made changes that affect the text and the userforms in the letters (changes are not the same in all letters), so I want to make my life easier and open a group of them at one time and unlock them...all in one keystroke (the macro).

    I put the "\" in and all the files in the selected folder will open now, however, they are still locked. What do I need to change to get the macro to unlock each of them as they are opened, or is that not possible? Here's the part of the code that I added the password into:

    [vba]Do While getFile <> ""
    strFile = path & getFile
    Documents.Open FileName:=strFile, passwordtemplate:="mypassword"
    getFile = Dir
    Loop
    [/vba]

  4. #24
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Sigh.

    What kind of password? If it is a password for editing, that is, a protection password, then use Unprotect after the file is open. It is an opening password, then your code should work.
    I would like to have these combined into fewer files, but the people requesting these templates do NOT want that. So, I need to work with what I have.
    Sorry, but I am STILL not buying this. So you have a bunch to work with. WHY, WHY, WHY do you feel you have to have them all open at the same time?????

Posting Permissions

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