Solved

Word 2010 Recommend Read Only Batch file

Posted on 2013-01-08
6
501 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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 200 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

772 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