Solved

Word 2010 Recommend Read Only Batch file

Posted on 2013-01-08
6
520 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

 
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
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 …

628 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