Getting embedded Excel range displayed in Word document using VBA

Zyg D

New Member
Joined
Aug 17, 2013
Messages
33
In my Word document there are many embedded Excel spreadsheets. Usually these Excel embeddings are bigger than the small portion shown in Word. I don't want to mess with the whole sheet when I enter the embedded file, I need to edit only this small area which is seen in Word. I know that it is only a picture, but when you <code style="margin: 0px; padding: 1px 5px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: pre-wrap; background: rgb(238, 238, 238);">ActiveDocument.InlineShapes(1).OLEFormat.Edit</code>, exactly the same small area opens in edit mode. I need to get the range of this area in order to be able to work only with this portion of the worksheet. I currently use these variables:

Code:
<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">[COLOR=#00008B]Dim[/COLOR] wrdActDoc [COLOR=#00008B]As[/COLOR] Document
[COLOR=#00008B]    Set[/COLOR] wrdActDoc = ActiveDocument
[COLOR=#00008B]Dim[/COLOR] oOleFormat [COLOR=#00008B]As[/COLOR] OLEFormat
[COLOR=#00008B]Dim[/COLOR] oWS [COLOR=#00008B]As[/COLOR] Excel.Worksheet
[COLOR=#00008B]    Set[/COLOR] oOleFormat = wrdActDoc.InlineShapes([COLOR=#800000]1[/COLOR]).OLEFormat
[COLOR=#00008B]    Set[/COLOR] oWS = oOleFormat.[COLOR=#00008B]Object[/COLOR].ActiveSheet</code>
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

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