本帖最后由 pd1 于 2022-11-7 16:43 编辑
保存为.bat 放在一级目录里面运行- <# :
- @echo off
- powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0' |Out-String|Invoke-Expression"
- pause
- #>
- dir |?{$_ -is [System.IO.DirectoryInfo]}|%{
- $filePath=$PWD.ToString()+"\"+$_.Name+".doc";
- $word = New-Object -ComObject word.application;
- $word.visible = $false;
- $doc = $word.documents.add();
- $selection = $word.selection;
- dir $_|%{
- $selection.InlineShapes.AddPicture($_.FullName);
- }
- $doc.saveas([ref] $filePath, [ref]$saveFormat::wdFormatDocument)
- $word.Quit();
- $doc=$null;
- $selection=$null;
- [GC]::Collect()
- }
复制代码
|