Question

I write large software manuals with over 200 screenshots. I am trying to automate some of the image formatting.

I edit pictures in Techsmith SnagIt and then paste into Word. I don't want to set the size in Snagit as I need the flexibility to move them around in Word.

I found the following code that resizes ALL images in a document based on existing width.

Sub PicSize_ALL_17cm()
Dim š As InlineShape
Dim Aspect As Double
For Each š In ActiveDocument.InlineShapes
    Aspect = š.Width / š.Height
    If (š.Width > CentimetersToPoints(11)) Then
        š.Width = CentimetersToPoints(11)
        š.Height = š.Width / Aspect
    End If
Next š
End Sub

While the majority of images are defined as 11 centimeters, on occasion, I need them to stay the full width of the page.

I was hoping I could assign a different style to these "full width" screenshots when I paste them in and then add some code to the above to ignore those images based on that style.

Any ideas?

Cheers,

Lynette

Was it helpful?

Solution

Sure put a character style on the image you want to preserve the size of as you paste it in. Then assuming you have set up a character style called Preserve, you can have code like.

Sub PicSize_ALL_17cm()
Dim š As InlineShape
Dim Aspect As Double
For Each š In ActiveDocument.InlineShapes
    if s.Range.Style <> "Preserve" then
         Aspect = š.Width / š.Height
         If (š.Width > CentimetersToPoints(11)) Then
             š.Width = CentimetersToPoints(11)
             š.Height = š.Width / Aspect
         End If
    End If
Next š
End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top