We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Image Display problem using Aspose word

Last week I downloaded an evaluation version of Aspose.Word for evaluation if this product matches to our requirement, and i have come across this Issue.
I am using Mail merge then pass a DataSet with all the fields required. When i open the file all the Merged fields have Data in them except the Merged Field whose value is Link to an Image.
I am providing my Code & my findings:

Dim objAsposeWord As Aspose.Words.Document
Dim license As Aspose.Words.License = New Aspose.Words.License
license.SetLicense("") 'Cannot find my License file so using Empty
strGuid = objGetGuid.getGUID
strDestination = System.Configuration.ConfigurationManager.AppSettings("DownloadDirectory") & "\" & strGuid
'Open Existing Doc file with Merge Fields
objAsposeWord = New Aspose.Words.Document("C:\STOCK.doc")


objAsposeWord.Save("C:\Test.htm", Aspose.Words.SaveFormat.Html) 

'Another Function to Save as DOC & Embedd Images


Public Function FormatWordDocument(ByRef strDocumentName As String) As Boolean
Dim objWordApp As New Word.ApplicationClass()
Dim objWordDoc As Word.Document
Dim oField As Word.Field

objWordDoc = objWordApp.Documents.Open(strDocumentName)

objWordDoc.PageSetup.TopMargin = 30
objWordDoc.PageSetup.LeftMargin = 30
objWordDoc.PageSetup.RightMargin = 30
objWordDoc.PageSetup.BottomMargin = 30
For Each oField In objWordDoc.Application.ActiveDocument.Fields

If oField.Type = Word.WdFieldType.wdFieldIncludePicture Then
oField.LinkFormat.SavePictureWithDocument = True
End If


objWordDoc.SaveAs(Replace(strDocumentName, "htm", "doc"), Word.WdSaveFormat.wdFormatDocument)


End Function

Here are My Findings :-
In my “Stock.Doc” I have a Merged Field which provides a links to a Image

Merged Field Name = "SmallImage"

Here is how i Create a DataRow Field in my Data Set

objDataRow("SmallImage") = "\\Server\Media\Images\Image.Jpg'>"

When i open my htm File, there is NO Image, All i see the Correct path to My Image

Then if i Look at the Page Source i see the following

<<img src='\\Server\Media\Images\Image.Jpg'>>

You can the Link to Image is Missing < before IMG SRC

<img src='\\Server\Media\Images\Image.Jpg'>

If i add < Manually and change the above text to

I can see the Image.

I cannot understand i am making a mistake, Because when i Create a Link in My DataSet the string is Fine.

Can you help?


Thanks for your inquiry. This occurs because you insert HTML into the document as plain text. You should use MergeField event handler for inserting HTML snippets into the document during mail merge. Please see the following link to learn more.
Hope this helps.
Best regards.

the link you refer to is invalid…does not go to anything…please correct


Thanks for your request and my apologizes for inconvenience. The link was broken after refactoring our documentation some time ago. Here is correct link to this article:
Hope this helps. Please let me know if you need more assistance, I will be glad to help you.
Best regards.