How can I get the displayed range of an embedded Excel worksheet in a PowerPoint slide via VBA?

jkim9312

New Member
Joined
Mar 29, 2022
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi, as the title explains, how do I gather the displayed range of an Excel OLE Object embedded in a PowerPoint slide via VBA? I've looked through the zipped files but I couldn't find anything in the .xlm files. I've noticed when you 'Edit' the OLE Object, the displayed range is captured by shaded border, see below for a picture.
2022-03-25_17-02-14.png

I'm trying to gather this information to copy the cells in range and paste them back into the slide as ppt table objects. This is so that I can ultimately extract the data via python.

I've tried several different VBA functions including wb.Windows(1).VisibleRange.Address, wb.ActiveSheet.UsedRange.Address, wb.Windows(1).Selection.Address but none of them accurately capture just the displayed data.

Also, I'm working with Office 365 on Windows!

Apologies if this is not the correct subforum. Let me know if it is and I will repost to the 'General Discussion & Other Applications' subforum.

Thank you!
 
Right. I should have probably added more context to my situation. I need to extract data from powerpoint files that's contained in either ppt table objects or embedded ole excel objects. We already have python code to extract the ppt table objects but am having difficulty in extracting the ole objects. I'm attempting to copy the displayed range in the powerpoint slides of the embedded ole excel objects which led me to where I am. However, we're open to other potential solutions. Do you have any suggestions on how to extract the data in the embedded ole excel objects?

Side note, I'm looking into Apache Tika and I'm not entirely sure if it satisfies my needs but it captures the displayed range in my sample file but not in the actual powerpoint files containing the data in scope of my project. Additionally, it doesn't look like the string result from Tika can be cleaned/transformed to a dataframe. So...idk
sorry - forgot a word 'in' in the 2nd paragraph.
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
sorry - forgot a word 'in' in the 2nd paragraph.
Again, I wish there was an edit option (sorry if there is and I'm completely missing it). The data ranges are dynamic for each embedded excel object which is why cannot just establish a static range. :(
 
Upvote 0
When you're editing your OLE object and adjusting the visible range, store the visible range as text in the AlternativeText property of the Shape object. Then refer to the AlternativeText property to copy and paste your range.

To store the visible range in the AlternativeText property, right click the OLE object, and select 'Edit Alt Text'. Then store your range in the alternative text window (ie. A1:C4). Now you can copy as follows . . .

VBA Code:
ws.Range(pptShape.AlternativeText).Copy

Will this work for you?
 
Upvote 0
When you're editing your OLE object and adjusting the visible range, store the visible range as text in the AlternativeText property of the Shape object. Then refer to the AlternativeText property to copy and paste your range.

To store the visible range in the AlternativeText property, right click the OLE object, and select 'Edit Alt Text'. Then store your range in the alternative text window (ie. A1:C4). Now you can copy as follows . . .

VBA Code:
ws.Range(pptShape.AlternativeText).Copy

Will this work for you?
Unfortunately, we have a large amount of ole objects/ppt files within scope and manually extracting the range is not feasible. Thanks again, Domenic.
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,185
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top