microsoft word macro help?

d0wnt0wn

Well-known Member
Joined
Oct 28, 2002
Messages
771
Hi Guys i know this is not the right place to ask this question but i can not seem to find a similar forum for vba help in word like there is here and you guys have helped me so much in the past that I thought I would give it a shot.

I am trying to make a macro for word that will allow me to select multiple pictures from a folder location and insert them in to the document evenly sized and i would like a text box inserted directly below each picture (or beside the picture)

any help or a point in the right direction would be greatly appreciated.

Ken
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi Ken,

Do you have a document to open or is it in a blank document?

If open do you have bookmarks in place

If new document is there an order to the pictures and textbox

Have you tried recording a macro in Word to do this as it will give you the code you need to repeat as and when.
 
Upvote 0
Hi Ken,

Do you have a document to open or is it in a blank document?

lets say it would start from a cursor position on an already open document

If open do you have bookmarks in place

not sure what this means :(

If new document is there an order to the pictures and textbox

no order for the pictures... it just needs to be picture, text box, picture, text box etc

Have you tried recording a macro in Word to do this as it will give you the code you need to repeat as and when.

sure i could use the macro for 1 picture at a time but I do not know how to make the macro dynamic for a varying amount of pictures.

Thanks for the help
 
Upvote 0
OK you would need to know the location of the pictures and the names of the pictures that you want to use and what type of picture i.e JPEG, GIFF etc.

So add them into the document you currently have Open.


Bookmarks helps you find certain places in Documents, example press F5 (Goto) and it will open the Find Replace and Goto feature, then you will see bookmarks.

Now to create a Bookmark in a location in the document you would select the position (don't which version you are using), the Insert Menu or Insert Tab, and Bookmark is at the bottom then give the Bookmark a name. Then use F5 again and select your Bookmark name and it takes you there.
 
Upvote 0
I guess a little more info would help.... basically i am using this for roof reports.. i take photos of roof problems and give them a little write up for each photo... I am using word 2010
 
Upvote 0
what i have done in the past, is take a new document, insert newspaper columns, and then import pictures one by one, this will take care of any scaling, lets word do the hard work

I used a macro to do this, will try and lay my hands on a copy
 
Upvote 0
i have a macro that get me close... but it does not have the text boxes


Sub InsertImages()
Dim fd As FileDialog
Dim oTbl As Table
Dim oILS As InlineShape
Dim vrtSelectedItem As Variant
If Documents.Count = 0 Then
If MsgBox("No document open!" & vbCr & vbCr & _
"Do you wish to create a new document to hold the images?", _
vbYesNo, "Insert Images") = vbYes Then
Documents.Add
Else
Exit Sub
End If
End If
'Add a 1 row 2 column table to take the images
Set oTbl = Selection.Tables.Add(Selection.Range, 1, 2)
oTbl.AutoFitBehavior (wdAutoFitFixed)
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.Title = "Select image files and click OK"
.Filters.Add "Images", "*.gif; *.jpg; *.jpeg; *.bmp; *.tif; *.png"
.FilterIndex = 2
If .Show = -1 Then
CaptionLabels.Add Name:="Picture"
For Each vrtSelectedItem In .SelectedItems
With Selection
Set oILS = .InlineShapes.AddPicture(FileName:= _
vrtSelectedItem, LinkToFile:=False, SaveWithDocument:=True, _
Range:=Selection.Range)
oILS.Range.InsertCaption Label:="Picture", TitleAutoText:="", Title:="", _
Position:=wdCaptionPositionBelow, ExcludeLabel:=0
.MoveRight wdCell, 1
End With
Next vrtSelectedItem
Else
End If
End With
If Len(oTbl.Rows.Last.Cells(1).Range) = 2 Then oTbl.Rows.Last.Delete
Set fd = Nothing
End Sub




I pressed f5 and saw the dialog box but still do not quite understand what the bookmarks use is.
 
Upvote 0
Sound advice. Let Word do the hard work for you.
 
Upvote 0
I appreciate the help guys but if anyone knows how to modify the code i have to add text boxes to it as well i would really appreciate that.
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,908
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top