InsertVideoLink.vb
C# VB
'''' This code is part of Document Solutions for Word demos.'' Copyright (c) MESCIUS inc. All rights reserved.''Imports System.IOImports System.LinqImports GrapeCity.Documents.Word
'' This demo shows how to insert a link to a YouTube video into an existing DOCX.Public Class InsertVideoLink Function CreateDocx() As GcWordDocument Dim doc = New GcWordDocument() '' Load an existing DOCX and find a specific location in it: doc.Load(Path.Combine("Resources", "WordDocs", "wetlands.docx")) Dim fr = doc.Body.Find("Reptiles and amphibians must return there to breed").First() '' Add picture with a thumbnail and a video link after the found paragraph: Dim par = fr.Range.ParentParagraph.Next Dim pic = par.AddRun().AddPicture() Dim picBytes = File.ReadAllBytes(Path.Combine("Resources", "ImagesBis", "wetlands.jpg")) pic.ImageData.SetImage(picBytes, "image/jpeg") pic.ImageData.WebVideoProperties.SetUrl("https://www.youtube.com/watch?v=k9UbKlBc3W4", "What are wetlands", 420, 300) pic.Size.Width.Value = 400 pic.Size.Height.Value = 300 '' Done: Return doc End FunctionEnd Class