ksor
02-04-2018, 04:45 AM
From Access I want to create a huge Word document with infos from the database.
At a point I want to get some pictures with a short text and put them into the document too - it works ... sometimes !
Often I get an error that the server is not avaiable - I can't see the pattern in this failing !
Here is my code for inserting the pictures - and when "the server is there" it works nicely:
Public Sub imageInsert(imgPath As String, txt As String, bD As Word.Document)
With Word.Application.Selection
.EndKey Unit:=wdStory
.InlineShapes.AddPicture imgPath, False, True
.MoveRight wdCharacter, 1
.TypeParagraph
.TypeText txt
.TypeParagraph
.TypeParagraph
.MoveUp wdLine, 3, wdExtend
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.EndKey wdStory
End With
End Sub
I must admit that i DON'T use my bD parameter which should be a reference to my huge document ..... I couldn't get it to work :banghead::banghead:
I used the "Word.Application,Selection" instead - but exactly THAT sometimes is failing !
I've tried to find some ".Selection" somewhere in my bD parameter but CAN'T :crying::crying:
How can I get the code to work with my bD parameter ( = big document) ?
At a point I want to get some pictures with a short text and put them into the document too - it works ... sometimes !
Often I get an error that the server is not avaiable - I can't see the pattern in this failing !
Here is my code for inserting the pictures - and when "the server is there" it works nicely:
Public Sub imageInsert(imgPath As String, txt As String, bD As Word.Document)
With Word.Application.Selection
.EndKey Unit:=wdStory
.InlineShapes.AddPicture imgPath, False, True
.MoveRight wdCharacter, 1
.TypeParagraph
.TypeText txt
.TypeParagraph
.TypeParagraph
.MoveUp wdLine, 3, wdExtend
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.EndKey wdStory
End With
End Sub
I must admit that i DON'T use my bD parameter which should be a reference to my huge document ..... I couldn't get it to work :banghead::banghead:
I used the "Word.Application,Selection" instead - but exactly THAT sometimes is failing !
I've tried to find some ".Selection" somewhere in my bD parameter but CAN'T :crying::crying:
How can I get the code to work with my bD parameter ( = big document) ?