![]() |
|
#1
|
|||
|
|||
![]()
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 Code:
chartObj.ChartArea.Copy Code:
bmRange.InlineShapes(1).Chart.ChartData.Activate bmRange.InlineShapes(1).Chart.ChartData.BreakLink |
#2
|
|||
|
|||
![]()
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 Code:
chartObj.ChartArea.Copy ![]() I'll leave the screen a bit and see if I can find a solution later... |
![]() |
Tags |
charts, copy, update |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
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 |
![]() |
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 |