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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Placing numerous photos within word document 1

Status
Not open for further replies.

daveonion

Programmer
Aug 21, 2002
359
GB
Hi,

I have numerous photos in a file and depending what the user wants to view I need to place these photos in a word document (so document could contain 1 photo or numerous). They need to be the same size, although currently they aren't, so roughly 2 photos per page would work. The problem i'm having is I have no idea how to force the program to place a photo on a new page and i have no idea how to specify where the cursor is placed, any help would be greatly appreciated.
 
Have you tried to play with the macrorecorder ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi yes I have,

the problem with it is when you insert a picture from file you cant then click on the picture and size it, whilst the macro is recording. So i have no idea what the code should be.
 
There are a number of ways to make this work. However, we needa bit more detail.

HOW are you getting the information from the user? By that I mean, by what method are you getting the instruction to put in 2 photos....or 13 photos? Is it a button in the document? A UserForm?

Gerry
 
Interesting that Word won't let us select the picture with the mouse while recording.

Not sure what the best practice is (I defer to fumei? here), but I was able to record code for a size change as follows.
1. start recording
2. insert picture
3. shift-back arrow (selects picture)
4. format menu -> picture -> size tab

Here is the resulting code.

Code:
'Insert picture (sPath is path to your picture)
    Selection.InlineShapes.AddPicture _
        FileName:= sPath, _
        LinkToFile:=False, _
        SaveWithDocument:=True

'Move cursor left and select picture    
    Selection.MoveLeft Unit:=wdCharacter, _   
      Count:=1, _
      Extend:=wdExtend

'Change size    
    Selection.InlineShapes(1).Height = 72#
    Selection.InlineShapes(1).Width = 95.75

Walter
 
That inserts the picture.

The reason I ask about the process, because there is an alternative. You could use ActiveX Image controls. You can programatically control these better. The Image control contains the image, and its properties vis-a-vis sizing, is in some ways easier.

Gerry
 
Sounds interesting. Can I get you to point me at an example or description of how it is done?

Walter
 
Hi with the active x objects does it give each instance a name, that would be great if it did
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top