[Excel]Referring to a list of name ranges and using VBA to copy the intended named object
Hi,
I'm trying export a series of graphs and tables from Excel to Power Point. I've named each graph / table, and have a list of these name ranges in a single column. I'm wanting to go through this list of name ranges, and then copy the referenced graph / table across. For example:
Graph is named Graph1, Table is named Table1 In the column of name ranges I have; Graph1, Table1, etc. I'm moving through the name range column using .offset() How do I get the VBA to see the text "Graph1" in the column, and then know to copy over Graph1?
Code so far, which I know isn't correct. ExpPPt_Table_Start is the table, and the offset refers to the name range column. At the moment it just copies the text in the cell, and not the named object itself. Set PPtShape = PPtSlide.Shapes(2) PPtShape.TextFrame.TextRange = [ExpPPt_Table_Start].Offset(Cnt, 4)
Posted Jan 23, 2023, 4:37 PM UTC
What is the point of Table1? Not saying there isn't one, but you can loop through the shapes themselves without resorting to an intermediary, e.g.,
Sorry, I have multiple data tables and graphs, I'd like to copy them all across to PowerPoint. Table1 was just an example. I'd like one table which summarises all object names, and then use that table for vba.
I’m truly sorry, I misspoke. I should’ve said, “What is the point of your list?” My point being that the Shapes are quote-unquote listed by virtue of being in the Shapes collection.
I have a large Excel doc. The idea of the list is that a User can name specific objects (tables, text, graphs) they want to export into PowerPoint, and not all objects - if that makes sense. All the User would have to do then is add the specific objects to the list, and click export.
Ahhhhh, there it is, I get it. (I think. /grin)
You could use my loop, looking for the items in the list (they would be identifiable as
s.Name). There are a few ways to do that, but the simplest from a programming perspective would be to bang the list into a dictionary, then when you spin through the shapes, see if that shape name matches a key in the dictionary.