Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-11-2025, 07:40 AM
Italophile Italophile is offline Updating tables in Word Windows 11 Updating tables in Word Office 2021
Expert
 
Join Date: Mar 2022
Posts: 554
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

The first mistake you have made is using Late Binding.
There is no value to using late binding in this instance. The only advantage to late binding is version independence, i.e. you can write code in a newer version and it will theoretically work in an older one. But that advantage is lost unless you also use late binding for the host application code as Office is usually installed as a package. It is better to use early binding when working with other Office applications and reserve late binding for other commonly used libraries, e.g. ADO or XML.

By adding a reference to the Excel library (Tools | References) and declaring the object variables with their correct types (eg. Dim chartObj As xl.Chart) you get the benefit of IntelliSense.



Instead of
Code:
chartObj.Copy
What you need is
Code:
chartObj.ChartArea.Copy
When pasted this will give you a linked chart but the link can be broken by adding something like
Code:
bmRange.InlineShapes(1).Chart.ChartData.Activate
bmRange.InlineShapes(1).Chart.ChartData.BreakLink
Reply With Quote
  #2  
Old 04-11-2025, 08:06 AM
BigMac'ro BigMac'ro is offline Updating tables in Word Windows 10 Updating tables in Word Office 2016
Novice
Updating tables in Word
 
Join Date: Feb 2025
Posts: 9
BigMac'ro is on a distinguished road
Default

Thank you for the quick answer! Using early binding is for sure better, and I even already had the library references checked. I now modified the variable declarations:
Code:
Dim xlApp As Excel.Application
    Dim xlRefWB As Excel.Workbook
    Dim xlDataWB As Excel.Workbook
    Dim xlSheet As Excel.Worksheet
    Dim chartObj As Excel.chartObject
    Dim i As Long, lastRow As Long
    Dim wordBookmark As String
    Dim filePath As String, sheetName As String, rangeOrChart As String
    Dim bmRange As Word.Range
But when using
Code:
chartObj.ChartArea.Copy
, runtime error 438 occurs
I'll leave the screen a bit and see if I can find a solution later...
Reply With Quote
Reply

Tags
charts, copy, update



Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating tables in Word Is there a way to stop macro modifications from undoing when Updating Word Linked Tables? soroush.kalantari Word VBA 3 06-27-2021 06:15 PM
Problem With Updating Linked Excel Tables in Word 2013 maverick1714 Word 6 09-30-2014 12:30 AM
Updating tables in Word Word 2013 Fields not updating awaywithpixie Word 1 09-10-2013 10:35 AM
Updating lists of figures/Tables in a protected document IHARKIS Word 0 03-02-2011 04:39 AM
Auto-updating basic math functions & cross-referencing tables FranklinBluth Word Tables 13 11-19-2009 10:26 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:12 AM.


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