Word VSTO - Change the absolute positions' type?

萝らか妹 提交于 2019-12-29 09:48:29

问题


I use the following VB.NET (VSTO) code to add a shape in 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

What this code does is, it adds a rectangle shape at cursor point and makes it transparent (both background and line).

Now I like to change the absolute positions' type. To explain further, when you select the rectangle shape, then if you select the Ribbon tab Format > Position > More Layout Options... as shown in the image below,

It will open the following dialog,

In the above dialog I like to change Column and Paragraph marked by the red rectangles into the type Margin. How to do this by code?


回答1:


Word provides a Macro recorder. You may use it to get the code generated for you in the background. Thus, you will find what properties and methods exactly should be used to get the job done. See Record or run a macro for more information.




回答2:


The solution to this was solved in the link below,

https://social.msdn.microsoft.com/Forums/vstudio/en-US/e69584d7-24fe-4396-9a82-26b7dae02584/word-vsto-change-the-absolute-positions-type?forum=vsto



来源:https://stackoverflow.com/questions/31682246/word-vsto-change-the-absolute-positions-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!