3.10.0.4
Fixed issue with Word Interop not loading Added support for PDF output
This commit is contained in:
@@ -422,7 +422,7 @@ function Add-CDDocumentCustomProfileValue
|
|||||||
$value = $obj.startMenuAppListVisibility
|
$value = $obj.startMenuAppListVisibility
|
||||||
if($value.IndexOf(", ") -eq -1)
|
if($value.IndexOf(", ") -eq -1)
|
||||||
{
|
{
|
||||||
$value = $value -replace ",",", " # Option values in json file has space afte , but value in object don't
|
$value = $value -replace ",",", " # Option values in json file has space after , but value in object don't
|
||||||
}
|
}
|
||||||
Invoke-TranslateOption $obj $prop -PropValue $value
|
Invoke-TranslateOption $obj $prop -PropValue $value
|
||||||
return $false
|
return $false
|
||||||
|
|||||||
@@ -10,15 +10,32 @@ function Invoke-InitializeModule
|
|||||||
{
|
{
|
||||||
if(!("Microsoft.Office.Interop.Word.Application" -as [Type]))
|
if(!("Microsoft.Office.Interop.Word.Application" -as [Type]))
|
||||||
{
|
{
|
||||||
|
$loaded = $false
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Add-Type -AssemblyName Microsoft.Office.Interop.Word
|
Add-Type -AssemblyName Microsoft.Office.Interop.Word
|
||||||
|
$loaded = $true
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$wordFile = Get-ChildItem -path "$($env:windir)\assembly\GAC_MSIL" -Filter "Microsoft.Office.Interop.Word.dll" -Recurse
|
||||||
|
if($wordFile -and $wordFile.Exists)
|
||||||
|
{
|
||||||
|
Add-Type -Path $wordFile.FullName
|
||||||
|
$loaded = $true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Write-LogError "Failed to add Word Interop type. Cannot create word documents. Verify that Word is installed properly." $_.Exception
|
Write-LogError "Failed to add Word Interop type. Cannot create word documents. Verify that Word is installed properly." $_.Exception
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(-not $loaded) {
|
||||||
|
Write-LogError "Word Interop type not found. Cannot create word documents. Verify that Word is installed properly." $_.Exception
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Add-OutputType ([PSCustomObject]@{
|
Add-OutputType ([PSCustomObject]@{
|
||||||
@@ -46,6 +63,9 @@ function Add-WordOptionsControl
|
|||||||
$global:spWordCustomProperties.Visibility = (?: ($global:cbWordDocumentationProperties.SelectedValue -ne "custom") "Collapsed" "Visible")
|
$global:spWordCustomProperties.Visibility = (?: ($global:cbWordDocumentationProperties.SelectedValue -ne "custom") "Collapsed" "Visible")
|
||||||
$global:txtWordCustomProperties.Visibility = (?: ($global:cbWordDocumentationProperties.SelectedValue -ne "custom") "Collapsed" "Visible")
|
$global:txtWordCustomProperties.Visibility = (?: ($global:cbWordDocumentationProperties.SelectedValue -ne "custom") "Collapsed" "Visible")
|
||||||
|
|
||||||
|
$global:cbWordDocumentationFormat.ItemsSource = ("[ { Name: `"Docx`",Value: `"docx`" }, { Name: `"PDF`",Value: `"pdf`" }]" | ConvertFrom-Json)
|
||||||
|
$global:cbWordDocumentationFormat.SelectedValue = (Get-Setting "Documentation" "WordDocumentFormat" "docx")
|
||||||
|
|
||||||
$global:cbWordDocumentationLevel.ItemsSource = ("[ { Name: `"Full`",Value: `"full`" }, { Name: `"Limited`",Value: `"limited`" }, { Name: `"Basic`",Value: `"basic`" }]" | ConvertFrom-Json)
|
$global:cbWordDocumentationLevel.ItemsSource = ("[ { Name: `"Full`",Value: `"full`" }, { Name: `"Limited`",Value: `"limited`" }, { Name: `"Basic`",Value: `"basic`" }]" | ConvertFrom-Json)
|
||||||
$global:cbWordDocumentationLevel.SelectedValue = (Get-Setting "Documentation" "WordDocumentationLevel" "full")
|
$global:cbWordDocumentationLevel.SelectedValue = (Get-Setting "Documentation" "WordDocumentationLevel" "full")
|
||||||
|
|
||||||
@@ -112,8 +132,9 @@ function Invoke-WordActivate
|
|||||||
|
|
||||||
function Invoke-WordPreProcessItems
|
function Invoke-WordPreProcessItems
|
||||||
{
|
{
|
||||||
Save-Setting "Documentation" "WordExportProperties" $global:cbWordDocumentationProperties.SelectedValue
|
Save-Setting "Documentation" "WordExportProperties" $global:cbWordDocumentationProperties.SelectedValue
|
||||||
Save-Setting "Documentation" "WordCustomDisplayProperties" $global:txtWordCustomProperties.Text
|
Save-Setting "Documentation" "WordCustomDisplayProperties" $global:txtWordCustomProperties.Text
|
||||||
|
Save-Setting "Documentation" "WordDocumentFormat" $global:cbWordDocumentationFormat.SelectedValue
|
||||||
Save-Setting "Documentation" "WordDocumentTemplate" $global:txtWordDocumentTemplate.Text
|
Save-Setting "Documentation" "WordDocumentTemplate" $global:txtWordDocumentTemplate.Text
|
||||||
Save-Setting "Documentation" "WordDocumentName" $global:txtWordDocumentName.Text
|
Save-Setting "Documentation" "WordDocumentName" $global:txtWordDocumentName.Text
|
||||||
|
|
||||||
@@ -384,6 +405,14 @@ function Invoke-WordPostProcessItems
|
|||||||
$script:doc.TablesOfFigures | ForEach-Object -Process { $_.Update() | Out-Null }
|
$script:doc.TablesOfFigures | ForEach-Object -Process { $_.Update() | Out-Null }
|
||||||
$script:doc.TablesOfAuthorities | ForEach-Object -Process { $_.Update() | Out-Null }
|
$script:doc.TablesOfAuthorities | ForEach-Object -Process { $_.Update() | Out-Null }
|
||||||
|
|
||||||
|
if($global:cbWordDocumentationFormat.SelectedValue -eq "pdf")
|
||||||
|
{
|
||||||
|
$format = [Microsoft.Office.Interop.Word.WdSaveFormat]::wdFormatPDF
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$format = [Microsoft.Office.Interop.Word.WdSaveFormat]::wdFormatDocumentDefault
|
||||||
|
}
|
||||||
|
|
||||||
$fileName = $global:txtWordDocumentName.Text
|
$fileName = $global:txtWordDocumentName.Text
|
||||||
if(-not $fileName)
|
if(-not $fileName)
|
||||||
{
|
{
|
||||||
@@ -392,7 +421,10 @@ function Invoke-WordPostProcessItems
|
|||||||
|
|
||||||
$fileName = Expand-FileName $fileName
|
$fileName = Expand-FileName $fileName
|
||||||
|
|
||||||
$format = [Microsoft.Office.Interop.Word.WdSaveFormat]::wdFormatDocumentDefault
|
if($format -eq [Microsoft.Office.Interop.Word.WdSaveFormat]::wdFormatPDF -and $fileName -notlike "*.pdf")
|
||||||
|
{
|
||||||
|
$fileName = [IO.Path]::ChangeExtension($fileName, ".pdf")
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,6 +57,13 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
<TextBox Text="" Name="txtWordCustomProperties" Margin="0,5,5,5" Grid.Row="1" Grid.Column="1"/>
|
<TextBox Text="" Name="txtWordCustomProperties" Margin="0,5,5,5" Grid.Row="1" Grid.Column="1"/>
|
||||||
|
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,5,5,0" Grid.Row="2">
|
||||||
|
<Label Content="Document format" />
|
||||||
|
<Rectangle Style="{DynamicResource InfoIcon}" ToolTip="Specify the output format eg Docx or PDF" />
|
||||||
|
</StackPanel>
|
||||||
|
<ComboBox Name="cbWordDocumentationFormat" Margin="0,5,0,0" MinWidth="250" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left"
|
||||||
|
DisplayMemberPath="Name" SelectedValuePath="Value" />
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid Grid.Row="1" Grid.ColumnSpan="2">
|
<Grid Grid.Row="1" Grid.ColumnSpan="2">
|
||||||
|
|||||||
Reference in New Issue
Block a user