2016-01-18 42 views
0

我想使用AppleScript更改PowerPoint(2011 Mac)幻灯片中选定文本的西方和亚洲字体设置。根据this,类似下面的内容应该可以工作。但是,我甚至不能得到文本范围选择,更不用说名称字体无法使用AppleScript在PowerPoint(Mac 2011)幻灯片中获取文本范围

tell application "Microsoft PowerPoint" 
    tell active window 
     set name of font of text range of selection to "Palatino" 
     set east asian name of font of text range of selection to "YuMincho" 
    end tell 
end tell 

这是结果。

error "Can’t get text range of selection." number -1728 from «class TObj» of «class SelO» 

实际上,下列问题出现相同的错误。

tell application "Microsoft PowerPoint" 
    tell active window 
     get text range of selection 
    end tell 
end tell 

另一方面,以下简单的VBA代码工作正常。

Sub HiraginoSansW2HelveticaNeueLight() 
    With ActiveWindow.Selection.TextRange.Font 
     .Name = "Palatino" 
     .NameFarEast = "YuMincho" 
    End With 
End Sub 

从本质上讲,VBA我想要做什么,但它涉及到使宏观和.PPTM格式,而不是标准的.pptx节能等,这是不是AppleScript的,我可以从菜单栏中访问一样方便。

任何人都可以帮助我获得AppleScrit的工作吗?

回答

1

某些命令需要指定窗口(甚至在tell active window块)

使用itsof it,像这样:

text range of selection of it 
text range of its selection 

一个AppleScript在简报长期的信息:使用font name of font而不是name of font

+0

现在我再次尝试它,它的工作!将'选择文本范围的字体的字体名称设置为'Arial'并且'将它的选择的文本范围的字体的东亚名称设置为'游明朝体'“都按预期工作。再次感谢! –

0

以下代码运行良好。

tell application "Microsoft PowerPoint" 
    tell active window 
     set font name of font of text range of selection of it to "Arial" 
     set east asian name of font of text range of selection of it to "游明朝体" 
    end tell 
end tell 
相关问题