通过AppleScript为PowerPoint中的图像设置alt文本值?
我想运行一个有点像这样的AppleScript:通过AppleScript为PowerPoint中的图像设置alt文本值?,applescript,powerpoint,Applescript,Powerpoint,我想运行一个有点像这样的AppleScript: tell application "Microsoft PowerPoint" repeat with tSlide in (get slides of active presentation) repeat with tPic in (get pictures of tSlide) set is_decorative of tPic to true end re
tell application "Microsoft PowerPoint"
repeat with tSlide in (get slides of active presentation)
repeat with tPic in (get pictures of tSlide)
set is_decorative of tPic to true
end repeat
end repeat
end tell
但是设置为真的tPic不起作用,我也不知道正确的咒语
更好的办法是,通过弹出一个显示图片的对话框,并在脚本运行时向用户询问,为每个图像设置“alt text”值
这些属性是否可以通过AppleScript访问?它可以在Windows上完成吗,或者以某种编程方式完成吗?我只是在Windows版本的PPT上拼凑了一点VBA(本例中为2016)
对于活动演示文稿中的每个图片,它会要求用户为该图片输入alt文本;如果它们提供alt文本,则会指定它。如果他们输入空白或删除已经存在的任何alt文本,则会将图像设置为装饰性
我还没有在Mac上测试过它,但它也应该在那里工作
Sub SetPicsDecorative()
Dim oSh As Shape
Dim oSl As Slide
For Each oSl In ActivePresentation.Slides
For Each oSh In oSl.Shapes
If oSh.Type = msoPicture Then
' Here's the meat of the thing
' Ask the user for Alt text
oSh.AlternativeText = InputBox("Enter alt text or press ENTER to skip:", _
"Alt text for " & oSh.Name, oSh.AlternativeText)
' If they didn't enter any alt text, assume that the image is decorative
If Len(oSh.AlternativeText) = 0 Then
oSh.Decorative = True
End If
End If ' msoPicture
Next
Next
End Sub
RE:“我不知道正确的咒语。”——你不是在写剧本的时候切掉了一只鸡的头并喝了它的血吗?对不起,我就是忍不住。如果我有PowerPoint,我会提供帮助,但唉,我使用的是Mac电脑,所以我不必使用任何Microsoft软件。我已经发布了Microsoft的AppleScript for Office for Mac参考PDF,请随时下载: