PDA

View Full Version : [SOLVED:] Insert Multiple Pictures



loverealesta
01-30-2014, 09:21 PM
Hi Guys,

This is Terence from Down Under (Australia).

I know similar threads have been created before, but would any of you be able to help me out here?

I have attached a word document with this thread.

So it is the condition report template my company uses to provide photos upon a rental tenancy commencement.

I would just like to know how to insert all the photos I have taken into the template at once.

Your help would be much appreciated.

11188

gmaxey
01-31-2014, 08:15 AM
You might try: http://gregmaxey.mvps.org/word_tip_pages/photo_gallery_add_in.html

macropod
01-31-2014, 04:35 PM
Loverealesta: I've had a look at the attachment and I must say that, apart from the fact you don't need (or want) picture content controls for this, it's not at all clear how a macro would determine which pictures go where. You also mention other threads that discuss similar issues. I assume you're including http://www.vbaexpress.com/forum/showthread.php?44473-Insert-Multiple-Pictures-Into-Table-Word-With-Macro&p=298057&viewfull=1#post298057. Have you tried the code there, and adapting it to your needs?

loverealesta
01-31-2014, 06:41 PM
Hi Macropod,

Thanks for your response. Embarrassingly, I was unable to tailer the code to my needs..

We are a real estate company. Before each tenant moves into a rental property, we provide them with a condition report, which has a number of pictures in it.

So basically we go to the property prior to the tenant moving in, and take a number of photos.

I would like to insert all the pictures into where each picture content control currently is.

And also the last picture would go on the last page as it is where we insert a picture of the keys.

Thanks again..

macropod
01-31-2014, 10:45 PM
You document has what appears to be two columns for the pictures, with one column titled 'Office Copy' and the other titled 'Tenant Copy'. How is the macro to determine which pictures go in each column? Furthermore, your table probably has the wrong row count for any rental property. It would be better to let the macro simply add rows as needed - which is what the one in the link does. Plus, if you were to split the report table in two - with a separate table for the keys, that would greatly simplify the coding, as the code could do its processing without worrying about what's happening with the 'last' row. Your 'keys' picture will probably need to be inserted manually anyway, as the macro won't have any way of identifying it.

Also, as I've already said, the picture content controls are neither needed nor wanted for a macro - they just get in the way. I'm not even sure why you'd want them when you're not using a macro.

loverealesta
02-01-2014, 03:55 AM
Hi Paul, the report is not split in two. We would normally print off two copies and highlight "office copy" or "tenant copy" with a highlighter.
The reason why the picture content controls were inserted was that when you double click on them, they allow them to insert one picture at a time.
So from my understanding, you are saying that I should try to come up with a code that makes the tables. Is this correct?
Sorry, I actually don't know Visual Basic at all and intend to learn it soon.. Thanks for your response.

macropod
02-01-2014, 06:49 AM
Yes, the idea is to let the macro add rows as required, without the complication of content controls. The attached shows what I'm suggesting. Simply run the 'AddPics' macro, then add your keys photo.

loverealesta
02-01-2014, 09:18 PM
Hi Paul, thank you very much for that. I tried to run the macro, but it says "Compile error: variable not defined". Is there any way I can fix it?

macropod
02-01-2014, 10:29 PM
I don't get that error. Indeed, since all the variables are defined in the AddPics sub as supplied - and the code uses the Option Explicit declaration to trap any undeclared/mis-named variables, I can only surmise you've changed something.

loverealesta
02-02-2014, 04:09 PM
I tried again on my company computer and it worked! Thank you very much, Paul. Have a lovely day.