• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 845
  • Last Modified:

borders and shading styles

Is there a way to specify borders and shading styles for images within a word document?  As i have over 100 images i would like to apply a style for.  
I am using word 2003.

0
LC7Web
Asked:
LC7Web
  • 3
  • 3
1 Solution
 
Joanne M. OrzechManager, Document Services CenterCommented:
Absolutely!  You can create a style for images and apply that style to all images in your document.  Is this what you're looking for?  It will apply a specific style and border/shading to all images.

If the images are all "normal" style, you should be able to run a search and replace routine which will change the formatting of each image. (Actually, I don't think the images must be all normal but for the sake of discussion, let's say they are).   It would be something like this:

First, record a macro that creates your style (in this case, the style is called "Image").

Sub Image()
    ActiveDocument.Styles.Add Name:="Image", Type:=wdStyleTypeParagraph
    With ActiveDocument.Styles("Image")
        .AutomaticallyUpdate = False
        .BaseStyle = "Normal"
        .NextParagraphStyle = "Image"
    End With
    With ActiveDocument.Styles("Image").Font
    With ActiveDocument.Styles("Image").ParagraphFormat
    End With
    ActiveDocument.Styles("Image").ParagraphFormat.TabStops.ClearAll
    With ActiveDocument.Styles("Image").ParagraphFormat
        With .Shading
            .Texture = wdTextureNone
            .ForegroundPatternColor = wdColorAutomatic
            .BackgroundPatternColor = wdColorAutomatic
        End With
        With .Borders(wdBorderLeft)
            .LineStyle = wdLineStyleSingle
            .LineWidth = wdLineWidth225pt
            .Color = wdColorBlue
        End With
        With .Borders(wdBorderRight)
            .LineStyle = wdLineStyleSingle
            .LineWidth = wdLineWidth225pt
            .Color = wdColorBlue
        End With
        With .Borders(wdBorderTop)
            .LineStyle = wdLineStyleSingle
            .LineWidth = wdLineWidth225pt
            .Color = wdColorBlue
        End With
        With .Borders(wdBorderBottom)
            .LineStyle = wdLineStyleSingle
            .LineWidth = wdLineWidth225pt
            .Color = wdColorBlue
        End With
        With .Borders
            .DistanceFromTop = 1
            .DistanceFromLeft = 4
            .DistanceFromBottom = 1
            .DistanceFromRight = 4
            .Shadow = True
        End With
    End With
    Selection.Style = ActiveDocument.Styles("Image")
End Sub

Then do a search and replace for each photo that has normal style applied and apply the image style:

Sub ApplyImage()
    Selection.HomeKey Unit:=wdStory
    Selection.Find.ClearFormatting
    Selection.Find.Style = ActiveDocument.Styles("Normal")
    Selection.Find.ParagraphFormat.Borders.Shadow = False
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Style = ActiveDocument.Styles("Image")
    Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False
    With Selection.Find
        .Text = "^g"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Or you could combine the two macros - create the style and then apply to all images all at once.  Hope this helps.


0
 
LC7WebAuthor Commented:
How exaclty do you specify what to search for?
0
 
LC7WebAuthor Commented:
If i use the Find and Replace dialog to search for Special>Graphic
How do i specify replace ^g with the new macro i created?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
Joanne M. OrzechManager, Document Services CenterCommented:
Here LC7 - just try this - this combines the two macros - just run it (providing you don't already have a style called "Image"):

Sub Image()
    ActiveDocument.Styles.Add Name:="Image", Type:=wdStyleTypeParagraph
    With ActiveDocument.Styles("Image")
        .AutomaticallyUpdate = False
        .BaseStyle = "Normal"
        .NextParagraphStyle = "Image"
    End With
    With ActiveDocument.Styles("Image").Font
    With ActiveDocument.Styles("Image").ParagraphFormat
    End With
    ActiveDocument.Styles("Image").ParagraphFormat.TabStops.ClearAll
    With ActiveDocument.Styles("Image").ParagraphFormat
        With .Shading
            .Texture = wdTextureNone
            .ForegroundPatternColor = wdColorAutomatic
            .BackgroundPatternColor = wdColorAutomatic
        End With
        With .Borders(wdBorderLeft)
            .LineStyle = wdLineStyleSingle
            .LineWidth = wdLineWidth225pt
            .Color = wdColorBlue
        End With
        With .Borders(wdBorderRight)
            .LineStyle = wdLineStyleSingle
            .LineWidth = wdLineWidth225pt
            .Color = wdColorBlue
        End With
        With .Borders(wdBorderTop)
            .LineStyle = wdLineStyleSingle
            .LineWidth = wdLineWidth225pt
            .Color = wdColorBlue
        End With
        With .Borders(wdBorderBottom)
            .LineStyle = wdLineStyleSingle
            .LineWidth = wdLineWidth225pt
            .Color = wdColorBlue
        End With
        With .Borders
            .DistanceFromTop = 1
            .DistanceFromLeft = 4
            .DistanceFromBottom = 1
            .DistanceFromRight = 4
            .Shadow = True
        End With
    End With
    Selection.Style = ActiveDocument.Styles("Image")
    Selection.HomeKey Unit:=wdStory
    Selection.Find.ClearFormatting
    Selection.Find.Style = ActiveDocument.Styles("Normal")
    Selection.Find.ParagraphFormat.Borders.Shadow = False
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Style = ActiveDocument.Styles("Image")
    Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False
    With Selection.Find
        .Text = "^g"
        .Replacement.Text = ""
        .Forward = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

0
 
LC7WebAuthor Commented:
Great, thanks!
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Thanks much LC!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now