Using the SetSize in the FormatPicture Dialog

F

Feederman

Hi Guys,

Im currently building an application to convert all pictures in a
document into a certain format. Im know my way around the object model
very well but have hit a serious brick wall when tryin to set the
Width's and Height's of a InlineShape.

Due to the nature of the application the new converted pictures must be
in an identical position and have the same width and height to the
original. Your probably thinkin, well just set the width and height
using InlineShape.Width = etc. Well ofcourse this works but as far as
I can see it doesn't always work to exact precision when using
numbers with a decimal place. I.e You don't always get the width
/height that are shown in the FormatPicture dialog in word.

The only way I have found to get these values is to talk to the format
picture dialog itself. If im missing something here and there is a way
to work to exact precision using .WIdth and .Height please let me know!

Using the old nasty interface you can access the following propertys
for the format picture dialog for the selected object.

SetSize, CropLeft, CropRight, CropTop, CropBottom, ScaleX, ScaleY,
SizeX, SizeY

The code below Gets SizeX (Width) and works fine.

Word.Dialog dlg =
aShape.Application.Dialogs.Item(Word.WdWordDialog.wdDialogFormatPicture);


String width = GetPropertyFromDialog(dlg, "SizeX").ToString();

private static object GetPropertyFromDialog(Word.Dialog dlg, string
memberName)
{
Type dlgType = dlg.GetType();

return dlgType.InvokeMember(memberName,
BindingFlags.GetProperty | BindingFlags.Public |
BindingFlags.Instance,
null, dlg, null);
}

So once ive insterted my new picture I need to set its width and height
to that of the original. You would think you could just call set SizeX
with InvokeMember and the SetProperty flag and it would work, nah that
would be too easy! Unfortunatly this doesn't work as the ScaleX
property seems to override whatever you set the SizeX too. So if ScaleX
= 50% and I set SizeX = 10, ScaleX should be recalcaulated but its not,
even after you call dlg.Execute();

Theres one property of the FormatPicture dialog that I think could
could be my savoir, "SetSize". By the sounds of it, this would
allow me to set the size as if I had typed it into the dialog myself
and therefore work to precision. Unfortunatly due to Microsofts lack
of documentation I have no idea what type of object to pass it as the
arguments. Ive tried (Width, Height) a Size Structure all sorts, all
result in exceptions. Ive looked everywhere on the net to try to
find out what the parameter types are but have no success. So you guys
are my last hope, does anyone know what SetSize takes, or anyone willin
to make an educated guess, im that desperate lol!

Thanks for your help as always, where would I be without GoogleGroups
I don't know!

Cheers

Simon Turner
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top