2017-04-18 1 views
1

"Arial"로 표현 된 모든 글꼴을 대체 할 매크로를 개발하려고했습니다. 지금까지 필자는 텍스트 상자, 표 및 SmartArt의 글꼴 대체에 성공했지만 그룹화 된 개체의 글꼴을 대체 할 수 없었습니다. 다음은 참조 용 코드입니다. 아무도 도와 줄 수 있습니까?그룹화 된 개체의 글꼴 바꾸기 - Powerpoint 365

하위 TextFonts()

Dim oSl As Slide 
Dim oSh As Shape 
Dim oTbl As Table 
Dim oSmt As SmartArt 
Dim oNode As SmartArtNode 

Dim lRow As Long 
Dim lCol As Long 
Dim sFontName As String 

sFontName = "Arial" 

With ActivePresentation 
    For Each oSl In .Slides 
     For Each oSh In oSl.Shapes 
      With oSh 
       If .HasTextFrame Then 
        If .TextFrame.HasText Then 
         .TextFrame.TextRange.Font.Name = sFontName 
        End If 
       End If 
      End With 
     Next 
    Next 
End With 

For Each oSh In oSl.Shapes 
    If oSh.HasTable Then 
     Set oTbl = oSh.Table 
     For lRow = 1 To oTbl.Rows.Count 
      For lCol = 1 To oTbl.Columns.Count 
       With oTbl.Cell(lRow, lCol).Shape.TextFrame.TextRange 
        .Font.Name = "Arial" 
       End With 
      Next 
     Next 
    ElseIf oSh.HasSmartArt Then 
     For Each oNode In oSh.SmartArt.AllNodes 
      oNode.TextFrame2.TextRange.Font.Name = "Arial" 
     Next 
    End If 
Next 

다음 OSL 끝 하위

답변

0

가정 OSHP입니다 그룹화 된 객체 (당신은 모든 모양을 통해 쉽게 루프가이 그룹화 된 도형의 여부를 테스트 여부를 OSHP 경우, 수 .type = msoGroup 후 .... 는 당신은 요 언급

Dim li As Long 
    Dim oshp As Shape 

    Set oshp = powerpoint.shape 

If oshp.type = msoGroup then 

      For li = 1 To oshp.GroupItems.count 
      ' you can add some code here for finding a particular shape based on certain properties 
      oshp.GroupItems(li).Select 
      if oshp.type=rectangle etc etc 
      Next 

코드에 의해 각각의 모양에 액세스 할 수 있습니다 위의 u는 동일하게 유지됩니다. 이것은 단순히 막연한 설명이지만, 당신이 선택한 하나의 글꼴로 전체 프레젠테이션을 대체하기 위해 그것을

+0

감사합니다 – Krishna

0

코드를 얻을 것이다 : 팁을위한

Sub TextFonts() 

Dim oSl As Slide 
Dim oSh As Shape 
Dim oTbl As Table 
Dim oSmt As SmartArt 
Dim oNode As SmartArtNode 

Dim lRow As Long 
Dim lCol As Long 
Dim X As Long 
Dim sFontName As String 

sFontName = "Arial" 


'Text Boxes 
With ActivePresentation 
    For Each oSl In .Slides 
     For Each oSh In oSl.Shapes 
      With oSh 
       If .HasTextFrame Then 
        If .TextFrame.HasText Then 
         .TextFrame.TextRange.Font.Name = sFontName 
        End If 
       End If 
      End With 
     Next 
    Next 
End With 

'Grouped Objects 
For Each oSl In ActivePresentation.Slides 
    For Each oSh In oSl.Shapes 
     With oSh 
      Select Case .Type 
      Case Is = msoGroup 
       For X = 1 To .GroupItems.Count 
        If .GroupItems(X).HasTextFrame Then 
         If .GroupItems(X).TextFrame.HasText Then 
           .GroupItems(X).TextFrame.TextRange.Font.Name = sFontName 
         End If 
        End If 
       Next X 
      End Select 
     End With ' oSh 
    Next oSh 
Next oSl 

'Smart Arts 
For Each oSl In ActivePresentation.Slides 
    For Each oSh In oSl.Shapes 
     If oSh.HasTable Then 
      Set oTbl = oSh.Table 
      For lRow = 1 To oTbl.Rows.Count 
       For lCol = 1 To oTbl.Columns.Count 
        With oTbl.Cell(lRow, lCol).Shape.TextFrame.TextRange 
         .Font.Name = sFontName 
        End With 
       Next 
      Next 
     ElseIf oSh.HasSmartArt Then 
      For Each oNode In oSh.SmartArt.AllNodes 
       oNode.TextFrame2.TextRange.Font.Name = sFontName 
      Next 
     End If 
    Next 
Next oSl 

End Sub 
관련 문제