Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Word 2010 Recommend Read Only Batch file

Posted on 2013-01-08
6
Medium Priority
?
531 Views
Last Modified: 2013-09-14
Does anybody have any suggestions on how to write a batch file which will scan all the files on a drive and convert them so that when they are opened up Word suggests that it's opened read-only (this option is under Save As->Tools->General Options
0
Comment
Question by:chrisryan43
  • 2
  • 2
  • 2
6 Comments
 
LVL 25

Expert Comment

by:Tony Giangreco
ID: 38755858
All you probably need to do is execute the atrrib.exe file for all documents and set the read-only attribute.

Like this: attrib.exe *.doc +r

You might also wanto to set read only security on the folder they use.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38755932
I don't know about a batch file, but it would be possible with a Word macro or, slightly more difficult, with a VBScript.
0
 

Author Comment

by:chrisryan43
ID: 38800913
Unfortunately i don't want to set the read only attribute on the file. I would like to set the flag which means Word suggests opening it ready only. I think a Word macro might be the only way but could be very fiddly

Many thanks
Chris
0
Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

 
LVL 25

Expert Comment

by:Tony Giangreco
ID: 38800924
How about going into the NTFS permisions and set all users to read only for those files?
0
 

Author Comment

by:chrisryan43
ID: 38800953
I still want the users to be able to get write access should they need it but i just want the prompt window to come up when the file is opened to recommend read only (which is an option within Word)
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 600 total points
ID: 38801077
This VBA code does a recursive search of the folder structure; it opens anything with an extension beginning with .do; sets the property and saves and closes the document.
Sub CallFindDocFiles()
    FindDocFiles "X:\", "*.do*"
End Sub

Sub FindDocFiles(strFolder As String, strFilePattern As String)
    Dim strFileName As String
    Dim strFolders() As String
    Dim iFolderCount As Integer
    Dim i As Integer
   
    'collect child folders
    strFileName = Dir$(strFolder & "\", vbDirectory)
    Do Until strFileName = ""
        If (GetAttr(strFolder & "\" & strFileName) And vbDirectory) = vbDirectory Then
            If Left$(strFileName, 1) <> "." Then
                ReDim Preserve strFolders(iFolderCount)
                strFolders(iFolderCount) = strFolder & "\" & strFileName
                iFolderCount = iFolderCount + 1
            End If
        End If
        strFileName = Dir$()
    Loop
   
    'process files in current folder
    strFileName = Dir$(strFolder & "\" & strFilePattern)
    Do Until strFileName = ""
        ProcessDocument strFolder & "\" & strFileName
        strFileName = Dir$()
    Loop
   
    'look through child folders
    For i = 0 To iFolderCount - 1
        FindDocFiles strFolders(i), strFilePattern
    Next i
End Sub

Sub ProcessDocument(strDocFullname As String)
    Dim doc As Word.Document
    Set doc = Documents.Open(strDocFullname)
    doc.ReadOnlyRecommended = True
    doc.Close wdSaveChanges
End Sub

Open in new window

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…

824 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