post #11 of 11
Quote:
Originally Posted by RoboX View Post

if I understand correctly, the only way to achieve the result sought by me is to use VBA writing of the command lines?
If yes, unfortunately, practically I have no idea how to do it, even where to start .
Again, what you are proposing is very very weak and is almost as good as having no password at all.


However, just combine the following:
* Get files in a directory: http://stackoverflow.com/questions/10380312/loop-through-files-in-a-folder-using-vba
* Set/Unset PW: http://msdn.microsoft.com/en-us/library/office/aa190093(v=office.10).aspx


ALT+F11 in Word to open the VBA editor. Something roughly like this:
Code:
Sub LoopThroughFiles()
    Dim MyObj As Object, MySource As Object, file As Variant
    Dim fpath as String

    fpath = "c:\testfolder\"
   file = Dir(fpath)
   While (file <> "")
      If InStr(file, "test") > 0 Then
         MsgBox "Setting" & file
         if(SetPwd(fpath & file,fpath & file,,"12345")) then
               MsgBox "Password set"
         elseif
               MsgBox "Password failed"
         end if
         Exit Sub
      End If
     file = Dir
  Wend
End Sub




Function SetPwd(strNoPwdFile As String, _
                strPwdFile As String, _
                Optional strOpenPwd As String, _
                Optional strModPwd As String) As Boolean
   
   
   On Error GoTo SetPwd_Err
   
   Documents.Open FileName:=strNoPwdFile
   With ActiveDocument
      .SaveAs FileName:=strPwdFile, _
              Password:=strOpenPwd, _
              WritePassword:=strModPwd
      .Close
   End With
   SetPwd = True

SetPwd_End:
   Exit Function

SetPwd_Err:
   MsgBox "Error #: " & Err.Number & vbCrLf _
      & Err.Description
   Resume SetPwd_End
End Function

Edited by DuckieHo - 9/24/13 at 11:09am
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply