PDA

View Full Version : Solved: Automatic Pictures



Anne Troy
06-06-2004, 04:31 PM
I've attached a document with 4 tables cells. What we want to do is allow the user to run the macro and:


Insert-Picture dialog comes up, and they choose a picture.
The picture is immediately resized to 3.5 cm wide and 4.5 cm tall, and should probably be places as inline with text.
The 3 tables cells to the right are immediately populated with the same picture.
:)

TonyJollans
06-06-2004, 05:25 PM
Hi Anne,

Not altogether sure where you are going with this but is something like this what you want ..
Sub Piccy()
If Selection.Information(wdWithInTable) Then
' So far, so good - for now assume 1 row 4 cells as sample
Selection.Tables(1).Rows(1).Cells(1).Select
Dialogs(wdDialogInsertPicture).Show
With Selection.Cells(1).Range.InlineShapes(1)
.LockAspectRatio = msoFalse
.Width = CentimetersToPoints(3.5)
.Height = CentimetersToPoints(4.5)
.Range.Copy
End With
Selection.Tables(1).Rows(1).Range.Paste
Else
' Error Message and Quit
End If
end sub

It'll need a bit of tidying up. Will your table always be one row of four empty columns? Should the insertion point be in it? should the cells be sized (or just the picture)? etc., etc. As I say, I'm not sure where you're going.

Anne Troy
06-06-2004, 05:27 PM
It's a beautiful thing, Tony.
Works great!

So...to use this, our user needs to:


Copy the code above.
Open their document that already has a one-row, 4-column table, formatted with centered paragraph formatting.
Hit Alt+F11 to get to the Visual Basic Editor (VBE)
Double-click ThisDocument on the left under their document's name.
Paste the code in the right-hand window.
Hit save to save the code permanently in this file.
Close the VBE.
To use the macro, they can either assign a toolbar button or shortcut key using Tools-Customize. They can save this file as a document template (DOT) and close it. Hit File-New and double-click it to get a new, blank document each time they want to do this with a new picture.

:)

FYI: I am asked questions elsewhere that I'm not always able to answer. When that happens, I'll ask here, and point the questioner here once resolved. That's the case with this one, and one of the reasons I left the HELP forums open to non-members. We don't want to force people to join.

JMP
06-07-2004, 12:28 PM
Thank you so much for this code!!

I need it to allow me to get photos of taxi drivers and resize them for Id cards and record files.

This will save so much time!

Cheers


John
NYks UK

Anne Troy
06-07-2004, 12:54 PM
So you tried it and it works for you?

JMP
06-07-2004, 01:17 PM
Anne

It works perfectly!

Cheers


John