返回列表 发帖
例如变量表存在export.txt
AAAA=1
BBBB=2
CCCC=3
  1. #@&cls&powershell "type '%~0'|out-string|iex"&pause&exit
  2. $a=new-object -com word.application
  3. $a.visible=1
  4. $b=$a.documents.open("$(dir export.docx)")
  5. type export.txt|%{
  6. $c=$_ -split '='
  7. $a.selection.find.execute($c[0],1,0,0,0,0,1,1,0,$c[1],2)
  8. }
  9. #$a.quit(-1,1,0)
复制代码
先测试一下看结果没问题再删除最后一行前面的注释#号就能自动保存了

TOP

回复 11# delab-1

运行有错误提示吗
测试是可以的
   

TOP

powershell区的置顶的教程就很好啊

https://learn.microsoft.com/zh-cn/office/vba/api/word.find.execute
https://learn.microsoft.com/zh-cn/office/vba/api/word(enumerations)

扩展后的可以看一下吗

TOP

返回列表