Skip to content

Commit 3db40cf

Browse files
update word install ps1
1 parent 0e55953 commit 3db40cf

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

Modules/IntelliTect.MicrosoftWord/tools/install.ps1

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
# ensure Microsoft.Office.Interop.Word.dll is installed.
3+
24
$wordAssemblyPath = "./Lib/WordInteropNugetPackage/lib/netstandard2.0/Microsoft.Office.Interop.Word.dll"
35

46
if (Test-Path $wordAssemblyPath -eq $false) {
@@ -17,32 +19,27 @@ if (Test-Path $wordAssemblyPath -eq $false) {
1719
Remove-Item $ZipFile
1820
}
1921

20-
# ensure word is installed.
2122

2223
try {
23-
add-type -AssemblyName 'Microsoft.Office.Interop.Word'
24-
}
25-
catch {
26-
try {
27-
if ($wordAssemblyPath -and (Test-Path $wordAssemblyPath)) {
28-
add-type -Path $wordAssemblyPath
29-
Write-Output "Microsoft.Office.Interop.Word.dll installed for module."
30-
}
31-
else {
32-
throw;
33-
}
24+
if ($wordAssemblyPath -and (Test-Path $wordAssemblyPath)) {
25+
add-type -Path $wordAssemblyPath
26+
Write-Output "Microsoft.Office.Interop.Word.dll installed for module."
3427
}
35-
catch {
36-
throw 'Error with install script. Unable to find Microsoft.Office.Interop.Word package (see https://www.nuget.org/packages/Microsoft.Office.Interop.Word)'
28+
else {
29+
throw;
3730
}
3831
}
32+
catch {
33+
throw 'Error with install script. Unable to find Microsoft.Office.Interop.Word package (see https://www.nuget.org/packages/Microsoft.Office.Interop.Word)'
34+
}
35+
3936

4037
try {
4138
# check if word is installed
4239
Write-Output "Checking for Microsoft Word installation. (Module requires existing Word Installation)"
4340
$Word = New-Object -ComObject word.application
4441
$Word.Quit([Microsoft.Office.Interop.Word.WdSaveOptions]::wdDoNotSaveChanges)
45-
Write-Output "Microsoft Word is installed."
42+
Write-Output "Microsoft Word is installed."
4643
}
4744
catch {
4845
throw 'Unable to find Microsoft Word. You must have an install of Microsoft Word in order to use this module.'

0 commit comments

Comments
 (0)