Solved

Solution for Simple Application.File search

Posted on 2014-02-05
2
194 Views
Last Modified: 2014-02-06
Found a new use for this old code utalizing application.filesearch. Trouble is this function is not available in MS Word 2007.   Quick 500 Points for a resolution.

Public Sub UnprotectBatch()

' Created 01/05/2004
' RESULT: Files found in the search are Unprotected
flocation = InputBox("Enter full path for the files to unprotect.", "Batch Unprotection")
If flocation = "" Then Exit Sub
Application.ScreenUpdating = False
Set fs = Application.FileSearch
    With fs
        .LookIn = flocation
        .SearchSubFolders = False
        .FileName = "*.doc"
        If .Execute() > 0 Then
            For i = 1 To .FoundFiles.Count
                Documents.Open fs.FoundFiles(i)
                On Error Resume Next
                ActiveDocument.Unprotect Password:="tbd"
                ActiveDocument.Save
                ActiveDocument.Close
            Next i
        Else
            MsgBox "There are no MS Word files found in the location specified."
        End If
    End With
End Sub
0
Comment
Question by:mcjann
2 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39836541
Hi,

pls try

Sub macro3()
Set fso = CreateObject("Scripting.FileSystemObject")
flocation = InputBox("Enter full path for the files to unprotect.", "Batch Unprotection")
If flocation = "" Then Exit Sub
On Error Resume Next
Set ObjFolder = fso.GetFolder(flocation)
On Error GoTo 0
If IsEmpty(ObjFolder) Then
    MsgBox "Folder not valid"
    Exit Sub
End If
Set ObjFiles = ObjFolder.Files
For Each ObjFile In ObjFiles
    If ObjFile.Name Like "*.doc" Then
        Documents.Open (ObjFile.Name)
        On Error Resume Next
        ActiveDocument.Unprotect Password:="tbd"
        ActiveDocument.Save
        ActiveDocument.Close
    End If
Next
If IsEmpty(ObjFiles) Then MsgBox "There are no MS Word files found in the location specified."
End Sub

Open in new window

EDIT Filter *.doc Documents

Regards
0
 
LVL 1

Author Closing Comment

by:mcjann
ID: 39839552
I appreciate the solution and not just a link to follow.

500 Points awarded.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sorting in Excel with Group Headers if the Exist 2 82
I want to make a copying program for vbs 1 35
Running Visio Macro from VBS File 3 54
Problem to open text file 11 67
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Viewers will learn the different options available in the Backstage view in Excel 2013.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now