-1

我需要知道的是選定的字形藝術與否。在powerpoint 2010中識別字藝術形狀類型

Shape has property「Type」(returns enum MsoShapeType)。 當我插入文字藝術並檢查此屬性時 - 它將返回msoAutoShape而不是msoTextEffect(使用AutoShapeType == msoShapeRectangle)。

我怎樣才能檢查spae是藝術字(不是通常的矩形與文本框)?

謝謝!

+0

檢查[此問題和答案](http://stackoverflow.com/questions/16019942/find-the-type-of-a-shape)。 –

+0

[This](http://stackoverflow.com/questions/16019942/find-the-type-of-a-shape)答案不正確。 Shape.Type屬性值的預期結果是「msoTextEffect」,Word藝術形狀的實際結果是「msoAutoShape」。那就是問題所在。所以我沒有想法如何確定某種形狀是字藝術。 – AntonKolesnikov

+0

「到目前爲止您嘗試了什麼」:我嘗試使用其他屬性來確定該形狀是字藝術,但沒有成功 - 該形狀看起來與矩形形狀+文本框相同。此外,我試圖谷歌任何解決方案。我已經在msdn網站上寫過有關bug(即藝術字Shape.Type!= msoTextEffect)的文章,但沒有得到任何反饋。 – AntonKolesnikov

回答

0

如果您選擇整體智能形狀或單擊智能藝術形狀內的文本或選擇智能藝術中的一種形狀,則ActiveWindow.Selection.ShapeRange(1)將返回智能形狀。

所以

If ActiveWindow.Selection.ShapeRange(1).HasSmartArt Then 
    Debug.Print "It's smart art" 
End if 

[編輯] 但正如你指出的那樣,這是一個的SmartArt,而不是藝術字。我的錯誤,對不起。 這裏沒有藝術字形狀;它更像是將藝術字格式應用於整體形狀或形狀內的文字的任何形狀。這包括格式化,如發光,反射,陰影等,或者可以是藝術字預設中的一種,預先選擇這些不同效果的組合。我添加了一個示例,可幫助識別應用了這些預設的形狀或形狀範圍內的文字。除了查看可能應用的各種屬性(發光,反射等)的每個運行和每個文本框之外,我沒有看到檢查用戶應用的藝術字格式的任何簡單方法。不幸的是,沒有WordArtFormat =無法告訴我們我們可以忽略它。它要麼是預設中的一個,要麼是-2,這可能意味着任何一件事情。

Sub WordArtist() 

    Dim oSh As Shape 
    Dim oRng As TextRange2 

    ' Has word art formatting been applied to 
    ' entire shape? 
    Set oSh = ActiveWindow.Selection.ShapeRange(1) 
    Debug.Print oSh.TextFrame2.WordArtFormat 

    ' Has it been applied to individual chunks of 
    ' text within the shape 
    For Each oRng In oSh.TextFrame2.TextRange.Runs 
     Debug.Print oRng.Font.WordArtFormat 
    Next 

    ' Note: 
    ' A result of -2 for the entire shape could mean 
    ' - No text in the shape; not really word art 
    ' - Mixed formatting 
    ' - Text/shape has had glow/shadow/reflection etc applied 
    '  rather than one of the preset WordArt selections 

End Sub 
+0

謝謝。但是智能藝術與藝術字不一樣。所以字藝術形狀將在HasSmartArt – AntonKolesnikov

+0

Woops中返回false。我的錯。抱歉。請參閱編輯版本。 –

+0

太棒了! @ steve-rindsberg,謝謝! Thas的工作。 – AntonKolesnikov