Solved

Word 2010 Recommend Read Only Batch file

Posted on 2013-01-08
6
517 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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 
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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
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 video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
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.

710 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