Search the Community
Showing results for tags 'ms word'.
-
Hello Forum! I have a Word VBA Macro that inserts an image. I rebuilt the same behavior in AutoIt. Everything works the same except of one tiny difference. In VBA the image does NOT move down when i manually press <ENTER> after the Macro was running. In Autoit the image DOES move down when i press <ENTER> after the Script was running. Adding the image is just the beginning of the script. More Text will be added after. When i press <END> and then <ENTER> the behavior is the same again as in VBA. I tryd already several things but i do not want to hack in a Send("{END}") VBA: ' LOGO ---------------------------------------------------------------------------------------------------------------------- Dim Img As String Dim inlineShape As inlineShape Dim shape As shape Img = "C:\Logo.png" Set inlineShape = Selection.InlineShapes.AddPicture(FileName:=Img, LinkToFile:=False, SaveWithDocument:=True) inlineShape.LockAspectRatio = msoTrue inlineShape.width = CentimetersToPoints(9.58) Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter Set shape = inlineShape.ConvertToShape shape.WrapFormat.Type = wdWrapMergeFront ' Set wrapping type to "Top and Bottom" < This is not wrong! ' Texts ------------------------------------------------------------------------------------------------------------------------ Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft Selection.ParagraphFormat.SpaceAfter = 10 'Selection.TypeParagraph AutoIt: #include <Word.au3> #include "WordConstants.au3" Global $oRange Global Const $wdAlignParagraphCenter = 1 ; Align Center Global Const $wdAlignParagraphLeft = 0 ; Align Left Global Const $wdWrapMergeFront = 4 ; In front of Text Global $Bild = @ScriptDir & "\Logo.png" Global $oWordApp = _Word_Create(); Start Word Global $oDoc = _Word_DocAdd($oWordApp); Create Document Global $oInlineShape = $oDoc.InlineShapes.AddPicture($Bild, False, True) $oInlineShape.LockAspectRatio = True $oInlineShape.width = CentimetersToPoints(9.58) $oRange = $oInlineShape.Range $oRange.ParagraphFormat.Alignment = $wdAlignParagraphCenter ; Center Global $oShape = $oInlineShape.ConvertToShape ; Convert InlineShape to Shape $oShape.WrapFormat.Type = $wdWrapMergeFront ; Set wrapping type to "Top and Bottom" < "MergeFront" selects "Top and Bottom" in Word $oRange = _Word_DocRangeSet($oDoc, 0) $oRange.ParagraphFormat.Alignment = $wdAlignParagraphLeft ; Align Left $oRange.ParagraphFormat.SpaceAfter = 10 ;$oWordApp.Selection.TypeParagraph ;$oRange.InsertAfter("Inserted text after range.") ;$oRange.EndKey($wdLine,0) ;$oRange.Text = @CRLF ;$oRange.Collapse($wdCollapseEnd)