View Single Post
~ Б0ЯИ Τ0 С0δЭ ~
9May2009,18:06  
SaswatPadhi's Avatar
Really nice question, so I decided to post the solution though it's late !!!

Took me too long to figure out !

The thing is, when you use objDoc.Shapes, the image ought to stay above everything else (may be text or image). You are not inserting shapes into any proper place in the doc, you are just adding it to the collection of shapes.
What you should use here is : objSelection.InlineShapes.

The correct script should be :
Code: vb
Set fsoFolder = CreateObject("Scripting.FileSystemObject")
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
Set objShape = objSelection.InlineShapes

objSelection.Font.Name = "Arial"
objSelection.Font.Size = "12"
Set folder = fsoFolder.GetFolder("C:\Documents and Settings\Rajesh\Desktop\Ricky files\TestPix")
Set files = folder.Files
for each objFile in files
    filepath = fsoFolder.GetAbsolutePathName(objFile)
    sName = objFile.Name
    iLen= len(sName) -4
    sNameNew = left(sName, iLen)
'   msgbox sName
    objShape.AddPicture(filepath)
    objSelection.TypeParagraph()
    objSelection.TypeText sNameNew
    objSelection.TypeParagraph()
    objSelection.TypeParagraph()

Next
set files = nothing
set folder = nothing
set fsoFolder = nothing

Last edited by SaswatPadhi; 9May2009 at 18:07.. Reason: Highlighted "Late Reply"