Image placement in word through excel

Baravelli

New Member
Joined
Jul 19, 2011
Messages
1
I know Excel VBA programming very well but nothing about VBA in Word. I have a lot of content stored in Excel. The content is stored database-style, where a record is a row and the columns contain specific data. Some of the data stored in cells are entire paragraphs and some are path names to images. I wish to display all of this information to word. I have no problem accessing any of my data in Excel. Nor do I have any problems opening a new Word object and adding text and pictures. My problem is that I don't know anything about formatting images in word.

My question is: Through Excel, how can I insert an entire paragraph of text, then insert a small picture, aligned right, with the text from the paragraph wrapped around it?

After getting the word object and setting up a new Word document "word_doc"....right now I've got:

'// using word and excel 2007
With word_doc
.Content.InsertParagraphAfter

.Content.InsertAfter ("Sample text to start things off. This text should be long enough to take up several lines in a normal Word document. I don't know if I need to insert the picture before or after this text. At any rate this text should be on the left and a picture should be inserted on the right side of the word document with this text wrapped around it. I have no fixed location where this might be. It might be on the 2nd page of the Word document that i am creating and it might be on the 10th page.")

'// this is where I set the range as the last paragraph inserted.
'// again, this is where I don't know how to navigate around in Word through VBA

Set text_range = .Range(Start:=.Paragraphs(.Paragraphs.Count).Range.Start, End:=.Paragraphs(.Paragraphs.Count).Range.End)
text_range.ParagraphFormat.Alignment = wdAlignParagraphLeft

'// I have the picture link for the line below
Set word_image = text_range.InlineShapes.AddPicture("C:....", False, True)

max_h = 100

With word_image
orig_h = .Height
orig_w = .Width
r = orig_h / orig_w
.Height = max_h
.Width = max_h / r
End With

.Content.InsertAfter ("Additional text to follow")
end with
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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