Microsoft.Office.Interop.Word.WdRelativeHorizontalPosition出现C#编译器错误;

我们的香蕉人

我有以下代码,用于在运行时修改Word文档中的文本框架。

这是在.NET Windows Forms应用程序中。

var oShapes = oWord.ActiveDocument.Shapes; 
var titleShape = oShapes["Title"];

var myWord = new Microsoft.Office.Interop.Word.Application();

titleShape.Height = myWord.InchesToPoints(1.75F);
titleShape.Width = myWord.InchesToPoints(0.45F);
titleShape.RelativeHorizontalPosition = Microsoft.Office.Interop.Word.WdRelativeHorizontalPosition;
titleShape.RelativeVerticalPosition =  Microsoft.Office.Interop.Word.WdRelativeVerticalPosition();
titleShape.Left = 4.35F;
titleShape.Top = 17.5F;
titleShape.TextFrame.WordWrap = 0;
titleShape.LockAnchor = 1;

var sTitle =string.Empty;

titleShape.TextFrame.TextRange.Text = DocumentType; // sTitle;
titleShape.TextFrame.AutoSize=-1;

不幸的是,我一定弄错了,因为Microsoft.Office.Interop.Word.WdRelativeHorizo​​ntalPosition; 在VS 2010中(以及下面的行中)显示为错误。

通过Office Interop使用像c#这样的单词枚举常量的正确方法是什么?

我们的香蕉人

我找到了它,我在调用枚举名称,而不是枚举常量。

所以 Microsoft.Office.Interop.Word.WdRelativeHorizontalPosition

应该

Microsoft.Office.Interop.Word.WdRelativeHorizontalPosition.wdRelativeHorizontalPositionPage;

(再加上我使用方括号认为是问题所在)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用参考C#添加Microsoft.Office.InterOp.Word

来自分类Dev

使用参考C#添加Microsoft.Office.InterOp.Word

来自分类Dev

C# Microsoft.Office.Interop.Word 保护段落

来自分类Dev

使用Microsoft.Office.Interop.Word

来自分类Dev

如何在C#中为Microsoft.office.interop.word实现后期绑定?

来自分类Dev

带有C#的Microsoft.Office.Interop.Word-标识现有目录对象

来自分类Dev

如何使用 Microsoft.Office.Interop.Word 在 C# 中编辑 docx 文件

来自分类Dev

Microsoft.Office.Interop.Word错误,在代码中打开文档文件

来自分类Dev

MSWord Shape对象Microsoft.Office.Interop.Word的C#COMException读取属性

来自分类Dev

C#Microsoft.Office.Interop.Word SpellingChecked不返回真实值

来自分类Dev

使用f#Microsoft.Office.Interop.Word搜索和替换

来自分类Dev

使用Microsoft.Office.Interop Word和Excel

来自分类Dev

在VBScript中使用Microsoft.Office.Interop.Word枚举常量

来自分类Dev

Microsoft.Interop.Office.Word完整样式不适用

来自分类Dev

使用Microsoft.Office.Interop.Word启用内置的Microsoft Word按钮控件

来自分类Dev

C# Microsoft.Office.Interop.Word 替换为 Selection.Find.Execute() 超过第一个单词

来自分类Dev

机器中的单独Microsoft.Office.Interop.Word实例和Word应用程序

来自分类Dev

如何通过 Microsoft.Office.Interop.Word 在 wdRevisionsViewFinal 中将 word 转换为 html?

来自分类Dev

C#使用Microsoft.Office.Interop.Excel读取数据

来自分类Dev

Office 2007的Microsoft.Office.Interop.Excel

来自分类Dev

在哪里可以找到Microsoft.Office.Interop.Word.dll(2010)?

来自分类Dev

在Microsoft.Office.Interop.Word中仅可访问的第一页

来自分类Dev

如何使用Excel.Microsoft.Office.Interop从Excel获取图表并将其添加到Word?

来自分类Dev

使用Microsoft.Office.Interop.Word查找所选单元格的索引

来自分类Dev

Microsoft.Office.Interop.Word中仅可访问的第一页

来自分类Dev

无法使用microsoft.office.interop.word在当前一字之后插入图像

来自分类Dev

将一个文档插入另一个 Microsoft.Office.Interop.Word

来自分类Dev

c# 如何在 Microsoft Interop Word 中编写

来自分类Dev

使用Microsoft.Office.Interop.Excel时出现错误;带有C#中控件新点语法的名称空间

Related 相关文章

  1. 1

    使用参考C#添加Microsoft.Office.InterOp.Word

  2. 2

    使用参考C#添加Microsoft.Office.InterOp.Word

  3. 3

    C# Microsoft.Office.Interop.Word 保护段落

  4. 4

    使用Microsoft.Office.Interop.Word

  5. 5

    如何在C#中为Microsoft.office.interop.word实现后期绑定?

  6. 6

    带有C#的Microsoft.Office.Interop.Word-标识现有目录对象

  7. 7

    如何使用 Microsoft.Office.Interop.Word 在 C# 中编辑 docx 文件

  8. 8

    Microsoft.Office.Interop.Word错误,在代码中打开文档文件

  9. 9

    MSWord Shape对象Microsoft.Office.Interop.Word的C#COMException读取属性

  10. 10

    C#Microsoft.Office.Interop.Word SpellingChecked不返回真实值

  11. 11

    使用f#Microsoft.Office.Interop.Word搜索和替换

  12. 12

    使用Microsoft.Office.Interop Word和Excel

  13. 13

    在VBScript中使用Microsoft.Office.Interop.Word枚举常量

  14. 14

    Microsoft.Interop.Office.Word完整样式不适用

  15. 15

    使用Microsoft.Office.Interop.Word启用内置的Microsoft Word按钮控件

  16. 16

    C# Microsoft.Office.Interop.Word 替换为 Selection.Find.Execute() 超过第一个单词

  17. 17

    机器中的单独Microsoft.Office.Interop.Word实例和Word应用程序

  18. 18

    如何通过 Microsoft.Office.Interop.Word 在 wdRevisionsViewFinal 中将 word 转换为 html?

  19. 19

    C#使用Microsoft.Office.Interop.Excel读取数据

  20. 20

    Office 2007的Microsoft.Office.Interop.Excel

  21. 21

    在哪里可以找到Microsoft.Office.Interop.Word.dll(2010)?

  22. 22

    在Microsoft.Office.Interop.Word中仅可访问的第一页

  23. 23

    如何使用Excel.Microsoft.Office.Interop从Excel获取图表并将其添加到Word?

  24. 24

    使用Microsoft.Office.Interop.Word查找所选单元格的索引

  25. 25

    Microsoft.Office.Interop.Word中仅可访问的第一页

  26. 26

    无法使用microsoft.office.interop.word在当前一字之后插入图像

  27. 27

    将一个文档插入另一个 Microsoft.Office.Interop.Word

  28. 28

    c# 如何在 Microsoft Interop Word 中编写

  29. 29

    使用Microsoft.Office.Interop.Excel时出现错误;带有C#中控件新点语法的名称空间

热门标签

归档