setting object width percentage

Forum home » Delegate support and help forum » Microsoft VBA Training and help » Setting Object Width as a percentage

Setting Object Width as a percentage

resolvedResolved · Medium Priority · Version 2003

Gregor has attended:
Excel Intermediate course

Setting Object Width as a percentage

I am creating a cimple Macro in Word. I have pasted in an Excel Object and want a macro that allows me to set the width of the object to 18.5 cm or 83%. This is easy to do, but when recording the macro the height defaults to 16.5cm (which is about 83% of the height of the object).

However, each object I paste into the Word document will be of different height (but the same width). Therefore the macro needs to set the object to 83% or 18.5cm and 83% of the height.

I have the following code in the macro:

Selection.InlineShapes(1).LockAspectRatio = msoTrue
Selection.InlineShapes(1).Height = 464.3
Selection.InlineShapes(1).Width = 524.4

How to I change the height to set to a percentage or change relative to a width of 524.4 (I am fairly new to VBA!).

Many thanks,

Gregor

RE: Setting Object Width as a percentage

Hi Gregor

With regards to your query it does fall beyond the scope of this forum as it is more consultancy related.

As you are new to VBA, you may want to review our Excel VBA Introduction training course which will provide a useful foundation to your VBA knowledge and may provide some useful pointers for your specific requirement.

for more information click here

If you would like to pursue the consultancy option then please advise so and we can follow up.

Regards

Jacob

Tue 21 Apr 2009: Automatically marked as resolved.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

VBA tip:

Count the Rows and Columns in a Selection

If you need to count the number of rows or columns in a worksheet use the following code:

Selection.Rows.Count - Returns the number of rows in the selection

Selection.Columns.Count - Returns the number of columns in the selection

Selection.CurrentRegion.Rows.Count - Returns the number of rows in the current region of the selection

View all VBA hints and tips


Server loaded in 0.05 secs.