Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to update multiple pictures 2

Status
Not open for further replies.

bibulous

Programmer
May 18, 2007
26
0
0
GB
Hi,

I often have to produce test scripts that include Screen shots.

I have two questions.

1) Can a macro be created to adjust all screen shots / pictures to the same size e.t.c
I can do this OK one picture at a time, if I select the picture & then play the macro. However I would like it to just do all pictures without me having to select them.

2) Is there a better way of inverting colours on these pictures. They are green screen shots, i.e. Black background & green text, which is a nightmare to print.
I can do this in two ways, either use Paint to invert the colours or use "Set Transparent Colour" in word. The second of these looks OK when printed, but looks awful in Word itself.

Any tips / advice e.t.c would be appreciated & save me a lot of time in the future.

Thanks,

Steven...
 
Hi Steven,

You can automatically re-size all shapes & inline shapes with code like:
Code:
Sub ReformatPics()
Dim oShp As Shape
Dim iShp As InlineShape
Dim sHWRatio As Single
With ActiveDocument
  For Each oShp In .Shapes
    With oShp
      If .Type = msoLinkedPicture Or .Type = msoPicture Then
        sHWRatio = .Height / .Width
        .Width = CentimetersToPoints(5)
        .Height = .Width * sHWRatio
      End If
    End With
  Next
  For Each iShp In .InlineShapes
    With iShp
      If .Type = wdInlineShapeLinkedPicture Or .Type = wdInlineShapePicture Then
        sHWRatio = .Height / .Width
        .Width = CentimetersToPoints(5)
        .Height = .Width * sHWRatio
      End If
    End With
  Next
End With
MsgBox "Finished Reformatting."
End Sub
This makes all the widths 5cm and scales the heights accordingly. If you're using imperial measurements, you can change 'CentimetersToPoints' to 'InchesToPoints'.

As for the colouring issues, you may be able to achieve what you're after by changing the image to grayscale & setting the black background transparent. You can do this by inserting:
Code:
        With .PictureFormat
          .ColorType = msoPictureGrayscale
          .TransparentBackground = True
          .TransparencyColor = RGB(0, 0, 0)
        End With
        .Fill.Visible = msoFalse
before both End If satements:
Code:
        .Height = .Width * sHWRatio
        '*CODE GOES HERE*!
      End If
However, the fact you're getting images with green text on a black background suggests you're copying screens from a mainframe or some other text-based screen, probably via emulation. In that case, you should be able to change the screen colours to give a dark text on a light (or white) background. Doing that, and changing the TransparencyColor value to suit could give much better results; indeed, with the right combo, you could change 'msoPictureGrayscale' to 'msoPictureBlackAndWhite' to boost the text density. The other possibility is to copy the screen text as text, and use a suitably-configured Style in Word to format it to look like a b/w screen.

Cheers

[MS MVP - Word]
 
That's fantastic, works like a treat.

I will have a play with the colour settings on the mainframe and in the code above, until I get what I want.

Thanks for your help,

Steven...
 
bibulous, as macropod gave you such a detailed response, and it seems to have helped, you should consider giving a star. Click the:

Thank macropod
for this valuable post

link. If you DO consider it valuable, giving a star shows appreciation AND also marks the thread as possibly significant for others. I know I am going to archive it myself.

As it is, I am going to give a star to macropod myself. That was an excellently written and clearly detailed (and useful) response.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top