[APAC]导入图片至Word,然后按规则命名(2/2)

#将所有docx文件改成可读
Set-ItemProperty -Path "e:\screenshot\*.docx" -Name IsReadOnly -Value $false
#从远端服务器剪切截图至本地
$target = "e:\screenshot"
$pw = ConvertTo-SecureString '密码' -AsPlainText -Force
$Creds = New-Object -Typename System.Management.Automation.PSCredential -Argumentlist "apac\814072", $pw
New-PSDrive -Name P -PSProvider FileSystem -Root "\\10.103.22.39\c$\ScreenShot" -Credential $Creds
Get-ChildItem -Path P:\ | Move-Item -Destination $target -Force
Remove-PSDrive -Name P
#文件名命名规则
$filename = (Get-Date).Tostring("yyyyMMdd")
#创建一个空的word文档,供Add-OSCPicture使用
$objWord = New-Object -ComObject Word.Application
$objWord.Visible = $false
$objDoc = $objWord.Documents.Add()
$objSelection = $objWord.Selection
$objDoc.SaveAs([ref]"e:\screenshot\$filename",[ref]16)
$objword.Quit()
#调用外部函数Add-OSCPicture,将多张图片依次导入word
Add-OSCPicture -WordDocumentPath "e:\screenshot\$filename.docx" -ImageFolderPath "e:\screenshot\"
#删除所有JPG文件
#Get-ChildItem -path *.JPEG | Remove-Item

 

转载于:https://www.cnblogs.com/IvanChen/p/4500775.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值