如何从C#更改Microsoft文档名称 [英] How to Change Microsoft Document name From C#

查看:125
本文介绍了如何从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的相应类库.有关更多信息,请参见: http://msdn .microsoft.com/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: http://msdn.microsoft.com/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文档名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆