I have multiple word documents, which need restrictions imposed on them from Developer mode.
I run the script using wscript passing a folder as argument, But it throes an error
Dim strFolder
Const xlTypePDF = 0
strFolder = WScript.Arguments(0)
if Wscript.Arguments.Count > 0 Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWord = CreateObject("Word.Application")
Set objFolder = objFSO.GetFolder(strFolder)
For Each Fil In objFolder.Files
Set objFile = objFSO.GetFile(Fil)
Set objDoc = objWord.Documents.Open(Fil,,TRUE)
dirPath = objFSO.GetParentFolderName(objFile)
fileBaseName = objFSO.GetBaseName(objFile)
'objWord.ActiveDocument.Unprotect Password:="pwd"
objWord.ActiveDocument.Close(False)
Next
objWord.Quit
Else
Msgbox("Run usning cmd")
End If
Fil
will just give you the name of the file, not the full path.. TrySet objDoc = objWord.Documents.Open(objFSO..BuildPath(strFolder, Fil),,TRUE)