Created
September 30, 2011 09:05
-
-
Save yoshimov/1253177 to your computer and use it in GitHub Desktop.
Windows Script to open Office files with read only.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim strFileName, strExt | |
Dim objApp | |
'Check arguments | |
If WScript.Arguments.Count <> 1 Then WScript.Quit | |
'get file name | |
strFileName = WScript.Arguments(0) | |
strExt = LCase(Right(strFileName, 4)) | |
Select Case strExt | |
Case "pptx", ".ppt" | |
'open powerpoint | |
Set objApp = WScript.CreateObject("Powerpoint.Application") | |
objApp.Visible = True | |
'open file with read only | |
Call objApp.Presentations.Open(strFileName,True) | |
Case "docx", ".doc" | |
'open word | |
Set objApp = WScript.CreateObject("Word.Application") | |
objApp.Visible = True | |
'open file with read only | |
Call objApp.Documents.Open(strFileName,,True) | |
Case "xlsx", ".xls" | |
'open excel | |
Set objApp = WScript.CreateObject("Excel.Application") | |
objApp.Visible = True | |
'open file with read only | |
Call objApp.Workbooks.Open(strFileName,,True) | |
End Select | |
'finish | |
Set objApp = Nothing | |
WScript.Quit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment