【发布时间】:2015-07-28 16:34:56
【问题描述】:
我使用以下 VB.NET (VSTO) 代码在 MS-Word 中添加形状,
Dim app As Word.Application = Globals.ThisAddIn.Application
Dim doc As Word.Document = app.ActiveDocument
Dim left As Single = CSng(Convert.ToDouble(app.Selection.Information(Word.WdInformation.wdHorizontalPositionRelativeToPage)))
Dim top As Single = CSng(Convert.ToDouble(app.Selection.Information(Word.WdInformation.wdVerticalPositionRelativeToPage)))
Dim shape As Word.Shape = doc.Shapes.AddShape(1, left, top, 225.1F, 224.5F)
shape.Fill.BackColor.RGB = ColorTranslator.ToOle(Color.Transparent)
shape.Fill.Visible = Microsoft.Office.Core.MsoTriState.msoFalse
shape.Fill.Transparency = 0.0F
shape.Line.Transparency = 0.0F
shape.Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse
这段代码的作用是,它在光标点添加一个矩形并使其透明(背景和线条)。
现在我想改变绝对位置的类型。进一步说明,当您选择矩形形状时,如果您选择功能区选项卡 格式 > 位置 > 更多布局选项...,如下图所示,
它将打开以下对话框,
在上面的对话框中,我喜欢将红色矩形标记的 Column 和 Paragraph 更改为 Margin 类型。如何通过代码做到这一点?
【问题讨论】:
标签: vb.net ms-word position vsto shape