Skip to content

Commit 0e3f77a

Browse files
fix paths in IntelliTect.MicrosoftWord install.ps1
1 parent 1f62679 commit 0e3f77a

2 files changed

Lines changed: 11 additions & 33 deletions

File tree

Modules/IntelliTect.MicrosoftWord/IntelliTect.MicrosoftWord.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
try {
2-
$wordAssemblyPath = "./Lib/WordInteropNugetPackage/lib/netstandard2.0/Microsoft.Office.Interop.Word.dll"
2+
$wordAssemblyPath = "$($PSScriptRoot)/Lib/WordInteropNugetPackage/lib/netstandard2.0/Microsoft.Office.Interop.Word.dll"
33
add-type -Path $wordAssemblyPath
44
}
55
catch {
Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,24 @@
11

22
# ensure Microsoft.Office.Interop.Word.dll is installed.
3+
$moduleRoot = (Split-Path $PSScriptRoot -Parent )
34

4-
$wordAssemblyPath = "./Lib/WordInteropNugetPackage/lib/netstandard2.0/Microsoft.Office.Interop.Word.dll"
5+
$wordAssemblyPath = "$($moduleRoot)/Lib/WordInteropNugetPackage/lib/netstandard2.0/Microsoft.Office.Interop.Word.dll"
56

6-
if (Test-Path $wordAssemblyPath -eq $false) {
7+
$ExtractPath = "$($moduleRoot)/Lib/WordInteropNugetPackage"
8+
9+
if ((Test-Path $wordAssemblyPath) -eq $false) {
10+
if ((Test-Path $ExtractPath) -eq $false) {
11+
New-Item -ItemType Directory -Force -Path $ExtractPath
12+
}
713
# this file despite running from the ./tools folder has a working dir of the root of the module
814
# get the latest word interop package and place the dll in the lib folder
915
$wordInteropNugetDownloadUrl = "https://www.nuget.org/api/v2/package/Microsoft.Office.Interop.Word"
1016

11-
$ZipFile = "./Lib/" + $(Split-Path -Path $wordInteropNugetDownloadUrl -Leaf) + ".zip"
12-
13-
$ExtractPath = "./Lib/WordInteropNugetPackage"
17+
$ZipFile = "$($moduleRoot)/Lib/" + $(Split-Path -Path $wordInteropNugetDownloadUrl -Leaf) + ".zip"
1418

1519
Invoke-WebRequest -Uri $wordInteropNugetDownloadUrl -OutFile $ZipFile
1620

1721
Expand-Archive -Path $ZipFile -DestinationPath $ExtractPath -Force
1822

1923
Remove-Item $ZipFile
20-
}
21-
22-
23-
try {
24-
if ($wordAssemblyPath -and (Test-Path $wordAssemblyPath)) {
25-
add-type -Path $wordAssemblyPath
26-
Write-Output "Microsoft.Office.Interop.Word.dll installed for module."
27-
}
28-
else {
29-
throw;
30-
}
31-
}
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-
36-
37-
try {
38-
# check if word is installed
39-
Write-Output "Checking for Microsoft Word installation. (Module requires existing Word Installation)"
40-
$Word = New-Object -ComObject word.application
41-
$Word.Quit([Microsoft.Office.Interop.Word.WdSaveOptions]::wdDoNotSaveChanges)
42-
Write-Output "✔ Microsoft Word is installed."
43-
}
44-
catch {
45-
throw 'Unable to find Microsoft Word. You must have an install of Microsoft Word in order to use this module.'
46-
}
24+
}

0 commit comments

Comments
 (0)