2016-07-11 2 views
1

단어 문서에 저장된 모든 이미지에 사전 또는 순회 방식으로 '그림 스타일'을 적용하는 쉬운 방법이 있습니까?단어 문서의 모든 그림에 그림 스타일 적용

나는 1

+0

당신은 확실히 그들을 통해 루프가 (각각 동일한 코드를 적용 할 수 있습니다 ... 단어 2010 나는 다른 버전을 테스트하지 않았에서 잘 작동 인라인 대 텍스트 래핑 된 모양). – Chris

답변

1

그림 스타일의 개념 만 UI 수준에 존재에 의해 그 일을 변경하지 않고 내가 문서에 추가하는 모든 이미지에 '센터 그림자 사각형'그림 스타일을 적용합니다. 이미지에 적용하려면 UI의 스타일의 속성을 확인하고 VBA 사용 하나씩 적용해야합니다 :

그냥 너희들 (그리고 다른 사람에 의해 영감을 얻었다
Sub FormatPictures() 

    Dim oInlineShape As inlineShape 
    For Each oInlineShape In ActiveDocument.InlineShapes 
     ApplyPictureStyleToInlineShape oInlineShape 
    Next 

    Dim oShape As Shape 
    For Each shape In ActiveDocument.Shapes 
     ApplyPictureStyleToShape oShape 
    Next 


End Sub 

Sub ApplyPictureStyleToInlineShape(shape As inlineShape) 

    ' borders 
    shape.Borders.Enable = False 

    ' fill 
    shape.Fill.Visible = msoFalse 

    ' line 
    shape.Line.Visible = msoFalse 

    ' shadow 
    shape.Shadow.Style = msoShadowStyleOuterShadow 
    shape.Shadow.Type = msoShadow21 
    shape.Shadow.ForeColor = WdColor.wdColorBlack 

    shape.Shadow.Transparency = 0.3 
    shape.Shadow.Size = 100 
    shape.Shadow.Blur = 15 
    shape.Shadow.OffsetX = 0 
    shape.Shadow.OffsetY = 0 

    ' reflection 
    shape.Reflection.Type = msoReflectionTypeNone 

    ' glow 
    shape.Glow.Radius = 0 
    shape.SoftEdge.Radius = 0 

End Sub 

Sub ApplyPictureStyleToShape(shape As shape) 

    ' fill 
    shape.Fill.Visible = msoFalse 

    ' line 
    shape.Line.Visible = msoFalse 

    ' shadow 
    shape.Shadow.Style = msoShadowStyleOuterShadow 
    shape.Shadow.Type = msoShadow21 
    shape.Shadow.ForeColor = WdColor.wdColorBlack 

    shape.Shadow.Transparency = 0.3 
    shape.Shadow.Size = 100 
    shape.Shadow.Blur = 15 
    shape.Shadow.OffsetX = 0 
    shape.Shadow.OffsetY = 0 

    ' reflection 
    shape.Reflection.Type = msoReflectionTypeNone 

    ' glow 
    shape.Glow.Radius = 0 
    shape.SoftEdge.Radius = 0 

End Sub 
0

, 너무 감사합니다 모두!), 그리고 내 자신의 매크로를 단일 테두리 (0.75 pt 너비)와 간단한 그림자 오프셋 3 pts로 오프셋 붙여 넣은 사진을 포맷 ...

그 매크로를 아이콘에 할당하고,

일단 이미지를 붙여 넣으면 (대부분 시스템의 절차 및 문서화를위한 스크린 샷입니다).

은 가능성이 조금 다를 수 있지만


Sub FormatPictureWithLineAndShadow() 
Dim oInlineShp As InlineShape 
For Each oInlineShp In Selection.InlineShapes 
    With oInlineShp 
    'Line border 
     With .Borders(wdBorderLeft) 
      .LineStyle = wdLineStyleSingle 
      .LineWidth = wdLineWidth075pt 
      .Color = wdColorAutomatic 
     End With 
     With .Borders(wdBorderRight) 
      .LineStyle = wdLineStyleSingle 
      .LineWidth = wdLineWidth075pt 
      .Color = wdColorAutomatic 
     End With 
     With .Borders(wdBorderTop) 
      .LineStyle = wdLineStyleSingle 
      .LineWidth = wdLineWidth075pt 
      .Color = wdColorAutomatic 
     End With 
     With .Borders(wdBorderBottom) 
      .LineStyle = wdLineStyleSingle 
      .LineWidth = wdLineWidth075pt 
      .Color = wdColorAutomatic 
     End With 
     ' shadow 
      .Shadow.Style = msoShadowStyleOuterShadow 
      .Shadow.Type = msoShadow21 
      .Shadow.ForeColor = WdColor.wdColorBlack 
      .Shadow.Transparency = 0.6 
      .Shadow.Size = 100 
      .Shadow.Blur = 5 
      .Shadow.OffsetX = 3 
      .Shadow.OffsetY = 3 
      ' reflection 
      .Reflection.Type = msoReflectionTypeNone 
      ' glow 
      .Glow.Radius = 0 
      .SoftEdge.Radius = 0 
End With 
    Next 
End Sub 
+0

모든 이미지를 미리 선택한 경우이 방법이 유용합니다. 그러나 문서 내에 이미지가 있고 문서의 텍스트가 아닌 모든 이미지에 대해 매크로를 실행하려면 어떻게해야합니까? 문서의 모든 이미지를 반복하도록 매크로를 조정하고 설정을 적용 할 수 있습니까? –

+0

추가 정보 : 문서에 다른 '이미지와 유사한'개체가있는 경우 매크로가 실패합니다 (예 : 내 경우에는 가로형 규칙 일 수 있음). 문서는


이있는 HTML 문서입니다. 따라서 매크로는 이미지 유형 객체에서만 작동해야합니다. 제 경우에는
코드를 모두 제거했으며 매크로가 잘 작동했습니다. –

관련 문제