NinjaGeek Posted June 11, 2010 Share Posted June 11, 2010 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.aspxThanks in advance for any help anyone can give. Link to comment Share on other sites More sharing options...
Authenticity Posted June 11, 2010 Share Posted June 11, 2010 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 Link to comment Share on other sites More sharing options...
NinjaGeek Posted June 11, 2010 Author Share Posted June 11, 2010 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.189So 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? Link to comment Share on other sites More sharing options...
Authenticity Posted June 11, 2010 Share Posted June 11, 2010 Shape and InlineShape are different objects. InlineShape, which is returned by _WordDocAddPicture, does not contain WrapFormat property.Look here for an example. Link to comment Share on other sites More sharing options...
NinjaGeek Posted June 11, 2010 Author Share Posted June 11, 2010 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!) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now