Formatting picture size in VBA

W

Wylie C

I have a macro that inserts a picture into a form field. I want to include
code within that procedure that formats the height and width of the picture
to 100x70 pixels. Can someone help me with the code?

Thank you.
 
C

Chuck

Looks like you have a couple of options:

Find a way to translate inches/centimeters/points to pixels and then set the
picture shape's height/width properties accordingly

Preset the picture's size in pixels in an image editing program (photoed.exe
for example) before insertion.

Unfortunate that Word VBA doesn't seem to handle pixels.
 
C

Chuck

Update:

I googled "convert pixels to inches" and came up with a bunch of links.
This one (http://www.classical-webdesigns.co.uk/pixelinchconvert.html)
provides a converter. However, you first need to know how many pixels (or
dots) per inch are in your display format (eg monitor or printer). Once
you've got an idea of how many pixels per inch (ppi) or dots per inch (dpi)
you're working with you can use set picture shape's height and width
properties accordingly.

For instance if your display format is 300 ppi, then your height and width
would be:

with yourshape
.Height = .Height = InchesToPoints(100 / 300)
.Width = InchesToPoints(70 / 300)
end with

Given the variability between display formats (different monitors/printers
have different dpi) have you considered using a different measurement than
pixels? Such as points, which is what Word seems to like best?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top