Guidance on Embedding Excel in Word using UiPath

@nidhi.goyal2,

Try this updated code.

' Add required namespaces for Word Interop
Imports Microsoft.Office.Interop.Word

' Define variables
Dim wordApp As Application = New Application()
Dim wordDoc As Microsoft.Office.Interop.Word.Document = wordApp.Documents.Open("C:\path\to\your\word\document.docx")

' Move to the desired location in the document where you want to insert the Excel file
Dim range As Microsoft.Office.Interop.Word.Range = wordDoc.Bookmarks("\endofdoc").Range

' Add the Excel object as an embedded OLE object in the Word document
' Note: Change the path to the actual location of your Excel file
range.InlineShapes.AddOLEObject(ClassType:="Excel.Sheet", _
                                FileName:="C:\path\to\your\excel\file.xlsx", _
                                LinkToFile:=False, _
                                DisplayAsIcon:=True)

' Save and close the document
wordDoc.Save()
wordDoc.Close()
wordApp.Quit()

' Release COM objects
System.Runtime.InteropServices.Marshal.ReleaseComObject(wordDoc)
System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp)