【发布时间】:2020-11-06 10:11:35
【问题描述】:
我正在尝试修改一些链接到其他 Excel 文件的 Excel 文件。
链接到的文件位于子目录中。我要将所有文件移动到根目录,然后运行脚本来更改链接。
我能够在每个文件中找到链接,但我无法修改它们(见下文)
有什么想法吗?
谢谢
P
#get all the excel files in the directory
Get-ChildItem $sourceDir -Filter *.xl* |
Foreach-Object {
write-host -ForegroundColor Yellow $_.FullName
$workbook = $excel.Workbooks.Open($_.FullName)
foreach ($link in $workbook.LinkSources(1))
{
write-host $link.Address
#this gives me .... C:\temp\files\childfile1.xlsx etc
# $link.Address seems to be read only?
#$link.Address = $newLink
#this doesn't seem to work either ...
#$workbook. .ChangeLink($link,$newlink,1)
}
#$workbook.Save()
$workbook.Close()
【问题讨论】:
-
写入主机 $Tab -ForegroundColor White $link.Address #Y:\Deirdre\Audit\Mgt Accts 2020\MGT ACCTS - Copy2\Phased Budget 2020.xlsx $link.Address = "C: \\temp\Finance\child.xlsx" write-host $Tab -ForegroundColor White $link.Address 在此对象上找不到属性“地址”。验证该属性是否存在并且可以设置。
标签: excel powershell