#1
|
|||
|
|||
Placing text and pictures in Word-document ??
Placing text and pictures in a WORD document.
Code:
Public Sub getBilleder(f As Form, bD As Word.Document) Dim tbl As DAO.Recordset Set tbl = CurrentDb.OpenRecordset("SELECT BILLEDE.*, BILLEDE.PersonID, BILLEDE.Sortering " & _ "FROM BILLEDE WHERE (((BILLEDE.PersonID)=" & Me.PersonID & _ ")) ORDER BY BILLEDE.Sortering;", dbOpenDynaset) With tbl .MoveFirst If .NoMatch Then Exit Sub bD.Content.InsertAfter ("Registrerede billeder: " & CrLf(2)) Do bD.Content.InsertAfter (.Fields("Billedtekst") & CrLf(1)) bD.Shapes.AddPicture (TrimFrom("Right", CurrentDb.Name, "\") & "IMG_files\" & .Fields("Sti til fil")) .MoveNext Loop Until .EOF End With Set tbl = Nothing End Sub How can I arrange the text and pictures something like this: Overall headline "Registrerede billeder: " & CrLf(2) Text for first picture: .Fields("Billedtekst") < a frame with the picture - the biggest thimbnail> Text for the second picture: .Fields("Billedtekst") < a frame with the picture - the biggest thimbnail> and so on for all pictures in the recordset |
#2
|
||||
|
||||
See, for example: https://www.msofficeforums.com/word-...html#post47919
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Quote:
(Keep It Simple Not Sophisticated !) |
#4
|
|||
|
|||
I think this is "best practice" inserted centered and one by one with text bolow each of them - simple and minimized:
Code:
Public Sub imageInsert(imgPath As String, txt As String, bD As Word.Document) Dim ksSel As Selection Set ksSel = Word.Application.Selection With ksSel .EndKey Unit:=wdStory .InlineShapes.AddPicture fileName:=imgPath, LinkToFile:=False, SaveWithDocument:=True .MoveRight Unit:=wdCharacter, Count:=1 .TypeParagraph .TypeText Text:=txt .TypeParagraph .MoveUp Unit:=wdLine, Count:=2, Extend:=wdExtend .ParagraphFormat.Alignment = wdAlignParagraphCenter .EndKey Unit:=wdStory End With Set ksSel = Nothing End Sub |
#5
|
||||
|
||||
Hardly. The use of selections instead of range objects is particularly inefficient and generates screen flicker. Furthermore, the whole point of using a table as my code does is so that you can ensure the image and its text can be assured of moving together.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Placing Endnotes in the Middle of a Document | lrosebush | Word | 3 | 10-24-2016 04:05 PM |
VBA to split word document containing pictures using delimter | uday.word | Word VBA | 5 | 09-11-2016 05:59 AM |
Formula for Placing Text in A Worksheet Group? | Margaret | Excel | 4 | 07-17-2016 11:54 PM |
Creating a (shared!) file with CommandButton placing AutoText into the document | thmsrox | Word VBA | 5 | 07-07-2016 05:04 AM |
Placing Image behind Text Box | alexei_lg | Word | 1 | 02-07-2012 12:28 PM |