AddVideoLink.vb
''
'' This code is part of Document Solutions for Word demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System.IO
Imports GrapeCity.Documents.Word

'' This demo shows how to add a link to a YouTube video that plays in the DOCX.
Public Class AddVideoLink
    Function CreateDocx() As GcWordDocument
        Dim doc = New GcWordDocument()
        doc.Body.AddParagraph("The picture below includes a link to a YouTube video which plays inside the document if clicked.")
        '' Add picture with a thumbnail and a video link inside:
        Dim vStyle = doc.Styles.Add("vlink_style", doc.Styles(BuiltInStyleId.BlockText))
        vStyle.ParagraphFormat.Indentation.LeftIndent = 0
        Dim par = doc.Body.AddParagraph()
        par.Style = vStyle
        Dim pic = par.AddRun().AddPicture()
        Dim picBytes = File.ReadAllBytes(Path.Combine("Resources", "ImagesBis", "mescius-video-thumbnail.jpg"))
        pic.ImageData.SetImage(picBytes, "image/jpeg")
        pic.ImageData.WebVideoProperties.SetUrl("https://www.youtube.com/watch?v=RRTCt2TTOyU", "How to Build a Simple Balance Sheet using C# .NET Excel APIs", 400, 400)
        pic.Size.Width.Value = 400
        pic.Size.Height.Value = 400
        ''
        doc.Body.AddParagraph("The End.")
        '' Done:
        Return doc
    End Function
End Class