-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtitle.ps1
27 lines (21 loc) · 1.07 KB
/
title.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
ps | where Name -eq winword | Stop-Process
Add-Type -AssemblyName Office
Add-Type -AssemblyName Microsoft.Office.Interop.Word
$p = 'Title'
$au = 'Abby'
#[array]$AryProperties = "Title"
#[array]$newValue = "Jim Title Text"
$application = New-Object -ComObject word.application
$application.Visible = $false
$binding = "System.Reflection.BindingFlags" -as [type]
$doc = Get-childitem -path "C:\JimM\jim_Template_Script_2017-02-16_0942.docx"
$document = $application.documents.open($doc.fullname)
$BuiltinProperties = $document.BuiltInDocumentProperties
$pn = [System.__ComObject].invokemember("item",$binding::GetProperty,$null,$BuiltinProperties,$p)
$result = [System.__ComObject].invokemember("value",$binding::SetProperty,$null,$pn,$au)
$pn
Write-Output 'End'
#$builtinPropertiesType = $builtinProperties.GetType()
#$BuiltInProperty = $builtinPropertiesType.invokemember("item",$binding::GetProperty,$null,$BuiltinProperties,$AryProperties)
#$BuiltInPropertyType = $BuiltInProperty.GetType()
#$BuiltInPropertyType.invokemember("value",$binding::SetProperty,$null,$BuiltInProperty,$newValue)