Solved

Word 2010 Recommend Read Only Batch file

Posted on 2013-01-08
6
482 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…

707 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

15 Experts available now in Live!

Get 1:1 Help Now