I try to convert the following code from VBA to AHK, which inserts water mark to chosen section of a document:
Code: Select all
ActiveDocument.Sections(1).Range.Select
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.Shapes.AddTextEffect(PowerPlusWaterMarkObject73958794, "DRAFT", "Calibri", 200, False, False, 0, 0).Select
Selection.ShapeRange.Name = "PowerPlusWaterMarkObject73958794"
Selection.ShapeRange.TextEffect.NormalizedHeight = False
Selection.ShapeRange.Line.Visible = False
Selection.ShapeRange.Fill.Visible = True
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(217, 217, 217)
Selection.ShapeRange.Fill.Transparency = 0.5
Selection.ShapeRange.Rotation = 315
Selection.ShapeRange.LockAspectRatio = True
Selection.ShapeRange.Height = CentimetersToPoints(8.62)
Selection.ShapeRange.Width = CentimetersToPoints(18.94)
Selection.ShapeRange.WrapFormat.AllowOverlap = True
Selection.ShapeRange.WrapFormat.Side = wdWrapNone
Selection.ShapeRange.WrapFormat.Type = 3
Selection.ShapeRange.RelativeHorizontalPosition = wdRelativeVerticalPositionMargin
Selection.ShapeRange.RelativeVerticalPosition = wdRelativeVerticalPositionMargin
Selection.ShapeRange.Left = wdShapeCenter
Selection.ShapeRange.Top = wdShapeCenter
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Code: Select all
oWord := ComObjActive("Word.Application")
oWord.ActiveDocument.Sections(1).Range.Select
oWord.ActiveWindow.ActivePane.View.SeekView := wdSeekCurrentPageHeader := 9
oWord.Selection.HeaderFooter.Shapes.AddTextEffect(0, "DRAFT", "Calibri", 200, WordFalse, WordFalse, 0, 0).Select
oWord.Selection.ShapeRange.TextEffect.NormalizedHeight := WordFalse
oWord.Selection.ShapeRange.Line.Visible := WordFalse
oWord.Selection.ShapeRange.Fill.Visible := WordTrue
oWord.Selection.ShapeRange.Fill.Solid
oWord.Selection.ShapeRange.Fill.ForeColor := 0xD9D9D9 ; .RGB(217, 217, 217)
;~ oWord.Selection.ShapeRange.Fill.Transparency := 0.5
;~ oWord.Selection.ShapeRange.Fill.Transparency := ComObject(VT_R4, 0.5)
oWord.Selection.ShapeRange.Rotation := 315
oWord.Selection.ShapeRange.LockAspectRatio := WordTrue
oWord.Selection.ShapeRange.Height.CentimetersToPoints(8.62)
oWord.Selection.ShapeRange.Width.CentimetersToPoints(18.94)
oWord.Selection.ShapeRange.WrapFormat.AllowOverlap := WordTrue
oWord.Selection.ShapeRange.WrapFormat.Side := wdWrapNone := 3
oWord.Selection.ShapeRange.WrapFormat.Type := 3
oWord.Selection.ShapeRange.RelativeHorizontalPosition := wdRelativeVerticalPositionMargin := 0
oWord.Selection.ShapeRange.RelativeVerticalPosition := wdRelativeVerticalPositionMargin := 0
oWord.Selection.ShapeRange.Left := wdShapeCenter := -999995
oWord.Selection.ShapeRange.Top := wdShapeCenter := -999995
oWord.ActiveWindow.ActivePane.View.SeekView := wdSeekMainDocument := 0
oWord := "" ; Clear global COM objects when done with them
Code: Select all
Error: 0x80020005 - Type mismatch
Specifically: Transparency
Code: Select all
Error: 0x800401F3 - Improper string of class
VBA object browser: FillFormat -> Transparency, Property Transparency As Single, Member of Word.FillFormat
Kind regards, mslonik