Thread: [Solved] Updating tables in Word
View Single Post
 
Old 04-15-2025, 07:40 AM
BigMac'ro BigMac'ro is offline Windows 10 Office 2016
Novice
 
Join Date: Feb 2025
Posts: 9
BigMac'ro is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
So use VBA code to change the link filenames. Trivial compared to what you're trying to do now. Even with inconsistent filenaming, all you need is a dialog box for selecting the source file. This can all be done from within Word and, depending on what you want to do can be done via DATABASE fields or possibly ADODB - the latter without even opening the workbook. Think about it.

Thanks for the input, macropod, that's for sure something I will think about! You say: "all you need is a dialog box for selecting the source file" - that's actually the key point: Around 50 graphs in the document, around 10 people working on it, so there are plenty of source files (that's why I try to gather them in a reference file)...


For the moment, I could achieve what I wanted to do with graphs. As often, a small mistake was hindering me: I noticed the graphs I am working with are not of type chartObject or Chart, but they are actually shapes! Therefore, the code in my previous post always jumped to the "else" condition.

I replaced this code block and now loop through the shapes:


Code:
Dim shp As Excel.Shape


For Each shp In xlSheet.Shapes
                    If shp.Type = msoChart And shp.Name = rangeOrChart Then
                        shp.Copy
                        If doc.Bookmarks.Exists(wordBookmark) Then
                            Set bmRange = doc.Bookmarks(wordBookmark).Range
                            bmRange.Paste
                            doc.Bookmarks.Add wordBookmark, bmRange
                        End If
                        chartFound = True
                        Exit For
                    End If
                  Next shp

Thanks again to both of you for your valuable guidance! Now, let's go for the tables in the document
Reply With Quote