0

There is a MS-Word document.

A Macro-Enabled Excel object was embedded.

I need setting the embedded Excel object's Height and Width with count of the -respectively- Rows and Columns are there involved.

enter image description here

As marked above picture with the red circles, it would be resizing by dragging with mouse.

How can perform this resizing with a macro in the embedded Excel's module?

Setting the Embedded object's height equal the count of Excel's Table Rows

Setting the Embedded object's width equal the count of Excel's Table Columns

Private Sub Worksheet_Change(ByVal Target As Range)

    'Automatically change the count of the rows and columns are in there in the embeded object's height and width.

    EmbeddedObjectHeight = Range("Table1").Rows.Count
    EmbeddedObjectWidth=Range("Table1").Columns.Count

End Sub
Community
  • 1
  • 1
Tuberose
  • 434
  • 6
  • 24
  • 1
    I doub't that you can access resizing of that object out of the embedded Excel. How can this Excel know that it is an embedded object? This resizing could be done from Word only but not from the embedded Excel file. – Pᴇʜ Jan 11 '18 at 09:27
  • This made the Embedded object resizing, same as a picture resizing, and made change the embedded object scale, against changing the count of row and column. – Tuberose Jan 11 '18 at 09:58
  • 3
    There is no way to change the size of the "window" that displays the Excel file using code. The only way I've ever found to achieve this is to CREATE the object from an existing Excel file. Then Word automatically calculates how many rows/columns should be displayed. If you're creating the object on-the-fly, automate an Excel application object in order to create the file, save it, close it, then insert it into Word. Afterwards you can delete the file. – Cindy Meister Jan 11 '18 at 16:39
  • I need this matter for my previous question [stackoverflow.com/q/](https://stackoverflow.com/q/48145123/9075944). I need copy a base Excel embedded object, several times. (As shown in my previous question). – Tuberose Jan 11 '18 at 17:00
  • Count of the Table Rows are in the embedded Excel object is determining in term of data entry, after added in the MS-Word Document. – Tuberose Jan 11 '18 at 17:24
  • 1
    Just the fact "you need this" dosn't change the fact that it is not possible. Maybe you are up the wrong three and asked the wrong question. – Pᴇʜ Jan 12 '18 at 07:04

0 Answers0