Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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,144
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 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
 

Tags
excel range, insert text from file



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 04:07 PM.


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