VBA 更改链接图片图像名称的代码,在 Powerpoint 中
VBA code to change linked picture image name , within Powerpoint
我有一个 Powerpoint,其中使用 Link 和 Insert 插入了图像。
我需要更改他们 link 的文件名。
我无法访问源文件夹。
因此需要更改为via VBA。
我可以更改文件夹位置,但不能更改文件名。
所有需要更改的是 'Doncaster' 到 'London'
- X:\Central\Buildings\District\Images\Forecast_Doncaster.png
X:\Central\Buildings\District\Images\History_Doncaster.png
X:\Central\Buildings\District\Images\Current_Doncaster.png
我试过了,但没用
submarket ="London"
sh.TextFrame.TextRange = Replace(sh.TextFrame.TextRange, "Doncaster", submarket
有人可以帮忙吗?
您发布的代码会将形状中的文本更改为图片,但不会 link。为此你需要更像这样的东西:
Sub Test()
Call EditLink(ActiveWindow.Selection.ShapeRange(1), ".png", ".jpg")
End Sub
Sub EditLink(oSh As Shape, strOriginalText As String, strNewText As String)
With oSh.LinkFormat
.SourceFullName = Replace(.SourceFullName, strOriginalText, strNewText)
End With
End Sub
在此示例中,我将 link 更改为指向与原始文件同名的 JPG,即 PNG。根据需要修改以更改项目的目录名称
对史蒂夫的回答稍作修改,我使用了它,它奏效了!谢谢你。
ActiveWindow.View.GotoSlide s.SlideIndex
Call EditLink(sh, "Doncaster", "London")
我有一个 Powerpoint,其中使用 Link 和 Insert 插入了图像。 我需要更改他们 link 的文件名。
我无法访问源文件夹。
因此需要更改为via VBA。
我可以更改文件夹位置,但不能更改文件名。
所有需要更改的是 'Doncaster' 到 'London'
- X:\Central\Buildings\District\Images\Forecast_Doncaster.png X:\Central\Buildings\District\Images\History_Doncaster.png X:\Central\Buildings\District\Images\Current_Doncaster.png
我试过了,但没用
submarket ="London"
sh.TextFrame.TextRange = Replace(sh.TextFrame.TextRange, "Doncaster", submarket
有人可以帮忙吗?
您发布的代码会将形状中的文本更改为图片,但不会 link。为此你需要更像这样的东西:
Sub Test()
Call EditLink(ActiveWindow.Selection.ShapeRange(1), ".png", ".jpg")
End Sub
Sub EditLink(oSh As Shape, strOriginalText As String, strNewText As String)
With oSh.LinkFormat
.SourceFullName = Replace(.SourceFullName, strOriginalText, strNewText)
End With
End Sub
在此示例中,我将 link 更改为指向与原始文件同名的 JPG,即 PNG。根据需要修改以更改项目的目录名称
对史蒂夫的回答稍作修改,我使用了它,它奏效了!谢谢你。
ActiveWindow.View.GotoSlide s.SlideIndex
Call EditLink(sh, "Doncaster", "London")