Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-14-2019, 05:11 PM
ChelseaCat ChelseaCat is offline Insert Range from Excel File into Word Windows 10 Insert Range from Excel File into Word Office 2010
Novice
Insert Range from Excel File into Word
 
Join Date: Apr 2019
Posts: 4
ChelseaCat is on a distinguished road
Default Insert Range from Excel File into Word

My apologies if this has been addressed elsewhere. I've been trying in both Word 2010 and Word 2013 to Insert > Text from file and choosing a named range in an Excel file. However, each time I try this I get the following message:
The file xxx cannot be opened because there are problems with the contents.
This occurs even when I create a brand new Excel file and save it. Am I doing something incorrectly or is there a different way to do what I want other than copying from Excel and pasting into Word?



Thanks in advance!
Reply With Quote
  #2  
Old 07-14-2019, 08:36 PM
gmayor's Avatar
gmayor gmayor is offline Insert Range from Excel File into Word Windows 10 Insert Range from Excel File into Word Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You cannot insert Excel ranges like this, only Word ranges. You can do it with a Word macro/ The following will paste the named range from the named file at the cursor:
Code:
Sub InsertExcelRange()
'Graham Mayor - https://www.gmayor.com - Last updated - 15 Jul 2019
Dim xlApp As Object
Dim xlWb As Object
Dim strWB As String
Dim bStarted As Boolean, bOpened As Boolean
Const strWorkbook As String = "workbook path"
Const xlRange As String = "excel range name"
    
    On Error Resume Next
    Set xlApp = GetObject(, "Excel.Application")
    If Err <> 0 Then
        Set xlApp = CreateObject("Excel.Application")
        bStarted = True
    End If
    On Error GoTo 0
    'Open the workbook to input the data
    strWB = Dir(strWorkbook)
    On Error Resume Next
    Set xlWb = xlApp.Workbooks(strWB)
    If xlWb Is Nothing Then
        Set xlWb = xlApp.Workbooks.Open(strWorkbook)
        bOpened = True
    End If
    On Error GoTo 0
    xlApp.GoTo Reference:="Pension"
    xlApp.Selection.Copy
    Selection.Paste
    If bOpened Then xlWb.Close 0
    If bStarted Then xlApp.Quit
lbl_Exit:
    Set xlApp = Nothing
    Set xlWb = Nothing
    Exit Sub
End Sub
Installing Macros
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 07-15-2019, 10:47 AM
ChelseaCat ChelseaCat is offline Insert Range from Excel File into Word Windows 10 Insert Range from Excel File into Word Office 2010
Novice
Insert Range from Excel File into Word
 
Join Date: Apr 2019
Posts: 4
ChelseaCat is on a distinguished road
Default

Thank you!!
Reply With Quote
Reply

Tags
excel range, insert text from file

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert image into powerpoint from cell in Excel file JJERINC PowerPoint 0 11-16-2018 09:05 AM
Insert Range from Excel File into Word Set Excel Range using Word gbrew584 Word VBA 3 12-07-2015 01:51 PM
OFFICE(Word,Excel..)-crash/close when DIALOG BOX launched of insert image,open file buggingme Office 1 05-30-2010 12:18 AM
Through VBA, export range from Excel to Word duugg Word VBA 0 08-24-2009 07:50 PM
Trying to insert hyperlink to excel file into Outlook KarenE Outlook 0 05-08-2006 12:56 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:07 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft