如何从C#更改Microsoft文档名称

编程入门 行业动态 更新时间:2024-10-27 06:27:08
本文介绍了如何从C#更改Microsoft文档名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我想知道你们是否知道如何从c#更改Microsoft Word应用程序的属性或文档名称或特定文档. 当我尝试:

Hello All, I was wondering if any of you know how to change property or Document name of Microsoft word application or specific documents from c#. When i try :

MyWord.Application aSheet; MyWord.Document sheet1; sheet1 = aSheet.Documents.Add(Missing.Value); sheet1.Name = " Sheet 1";

它返回以下错误: 错误属性或索引器Microsoft.Office.Interop.Word._Document.Name;无法分配给它-只读. 谢谢..

it returns following error: Error Property or indexer Microsoft.Office.Interop.Word._Document.Name; cannot be assigned to -- it is read only. Thanks..

推荐答案

这有点令人困惑.工作表在Excel中使用.根据您的代码,您正在尝试更改Word文档的名称. 例如,在保存文档时,您可以定义(Word)文档的名称.如果您尝试通过Interop使用Excel,请尝试使用Excel的相应类库.有关更多信息,请参见: msdn .microsoft/en-us/library/microsoft.office.interop.excel(v = office.14).aspx [ ^ ] This is a bit confusing. Sheets are used in Excel. Based on your code, you''re trying to change the name of the Word document. You can define the name of the (Word) document for example when saving the document. If you''re trying to use Excel via Interop, try using Excel''s corresponding class libraries. For more info, see: msdn.microsoft/en-us/library/microsoft.office.interop.excel(v=office.14).aspx[^]

Word没有工作表名称,因此您目前基本上处于错误的轨道. Word does not have sheet names so you are basically on the wrong track at the moment.

更多推荐

如何从C#更改Microsoft文档名称

本文发布于:2023-10-23 22:26:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1522178.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:名称   文档   Microsoft

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!