-
Read only recomended
I have this code to change the "Normal" style font. When a document that has the "recommend Read Only" it still open as read even though "ReadOnly:=False". I cannot figure this out. Any help appreciated.
Code:
Sub UpdateNormal()
Dim strPassword As String
strPassword = ""
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String
Dim SBar As Boolean, wdDoc As Document
SBar = Application.DisplayStatusBar
Application.DisplayStatusBar = True
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.docx", vbNormal)
While strFile <> ""
Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, ReadOnly:=False, _
AddToRecentFiles:=False, Visible:=True)
StatusBar = "Processing: " & strFile
With wdDoc
If wdDoc.ProtectionType <> wdNoProtection Then
wdDoc.Unprotect Password:=strPassword
End If
If .AttachedTemplate.Name = "Normal.dot" Then
.UpdateStylesOnOpen = True
.UpdateStylesOnOpen = False
End If
With wdDoc.Styles("Normal").Font
.NameFarEast = "+Body Asian"
.NameAscii = "Arial"
.NameOther = "Arial"
.Name = "Arial"
.Size = 11
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Scaling = 100
.Kerning = 0
.Animation = wdAnimationNone
.DisableCharacterSpaceGrid = False
.EmphasisMark = wdEmphasisMarkNone
.Ligatures = wdLigaturesNone
.NumberSpacing = wdNumberSpacingDefault
.NumberForm = wdNumberFormDefault
.StylisticSet = wdStylisticSetDefault
.ContextualAlternates = 0
End With
Application.ActiveDocument.Protect wdAllowOnlyReading, Password:=strPassword
With wdDoc
.Save
.Close
End With
End With
strFile = Dir()
Wend
Set wdDoc = Nothing
Application.DisplayStatusBar = SBar
Application.ScreenUpdating = True
End Sub
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function