PDA

View Full Version : Help o kind sir/madam! copy excel sheet to word by browsing for excel file from word



sarveshspace
11-11-2020, 09:12 PM
hello!
I would like to copy a sheet from an excel file to word . I would like to place the first sheet from the excel at a bookmark location in word.
I want to browse for the file from word and select the file and then paste it at the bookmark.

Private Sub CommandButton4_Click()
Dim FileToOpen As Variant
Dim OpenBook As Excel.Workbook
Application.ScreenUpdating = False
FileToOpen = Application.getopenfilename(Title:="Browse for your File & Import overlay", FileFilter:="Excel Files (*.xls*),*xls*")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
OpenBook.Sheets(1).Copy
ActiveDocument.Bookmarks("srspic").PasteSpecial xlPasteValues
OpenBook.Close False


End If
Application.ScreenUpdating = True
End Sub


for some reason, i get user type not defined error at excel.workbook.
i have enabled microsoft office 16 object library in references.

I would appreciate any help!
thanks!

I have attached the excel file for reference, I want to copy the overlay sheet from excel to word .

macropod
11-11-2020, 09:35 PM
Kindly don't post the same question multiple times.

Kindly post inter-op questions in the correct forum.

Kindly use the code tags when posting code.

Thread closed.