Sign in to follow this  
Followers 0
NinjaGeek

Word WrapFormat assignment

5 posts in this topic

Maybe I just don't entirely understand how COM objects work in AutoIt, but I don't know how to set the WrapFormat property for a Shape in MS Word. The code below is wrong, but says what I need to do:

#include <Word.au3>

$background = @MyDocumentsDir&"\image.jpg"

$oWordApp = _WordCreate ()
$oDoc = _WordDocGetCollection ($oWordApp, 0)
$oShape = _WordDocAddPicture ($oDoc, $background, 0, 1)
$oShape.WrapFormat.Type = "Microsoft.Office.Interop.Word.WdWrapType.wdWrapBehind"

The last line is where the problem is - that's the correct assignment value for the wdWrapBehind wrap type, but I don't know how to get AutoIt to do that assignment. Any help? The MSDN article on WdWrapType is at http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.wdwraptype.aspx

Thanks in advance for any help anyone can give.

Share this post


Link to post
Share on other sites

WdWrapType Enumeration. Usually, enumeration types hold numerical values.

I don't know if this is correct, but it should be:

$oShape.WrapFormat.Type = 5 ; wdWrapBehind

Share this post


Link to post
Share on other sites

I searched forever for that! Not sure how I missed it. I figured it would be a numerical value. It still isn't working though, for some reason it gives me the error:

>"C:\Documents and Settings\me\My Documents\Downloads\install\SciTe\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\me\Desktop\testit.au3"

C:\Documents and Settings\me\Desktop\testit.au3 (8) : ==> The requested action with this object has failed.:

$oShape.WrapFormat.Type = 5

$oShape.WrapFormat^ ERROR

>Exit code: 1 Time: 0.189

So it seems to fail at the .Type part of the command, but everyone I've looked I've seen it exactly like I have it - any idea why it would be doing this?

Share this post


Link to post
Share on other sites

Shape and InlineShape are different objects. InlineShape, which is returned by _WordDocAddPicture, does not contain WrapFormat property.

Look here for an example.

Share this post


Link to post
Share on other sites

Success!!

(I've been writing AutoIt scripts for the last 3 weeks straight (my work discovered that I had been using them to do half my job, and now is using me to automate half the workplace) and my brain is kind of fried. Thanks again, you rock!)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0