Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# VisualStudioVSTO附加模块。当MS Word文档';是从Web应用程序下载的吗?_C#_Visual Studio_Ms Word_Vsto - Fatal编程技术网

C# VisualStudioVSTO附加模块。当MS Word文档';是从Web应用程序下载的吗?

C# VisualStudioVSTO附加模块。当MS Word文档';是从Web应用程序下载的吗?,c#,visual-studio,ms-word,vsto,C#,Visual Studio,Ms Word,Vsto,我们的垂直SaaS ERP使用户能够管理文档。通过Web应用程序(文档直接从Web界面上传),我们还添加了MS Word VSTO插件,允许将文档从MS Word直接保存到云,并使用特定的数据库映射/逻辑 问题: 从Web应用程序下载MS Word文档(数据库id)时,我是否可以将唯一id(第122424-3213-23423行)插入其中 为什么我需要它(唯一id) 从MS Word更新文档时,我将使用此id映射/更新正确的文档 非常感谢您的帮助。据我所知,您希望向Word文档中添加一些元数据

我们的垂直SaaS ERP使用户能够管理文档。通过Web应用程序(文档直接从Web界面上传),我们还添加了MS Word VSTO插件,允许将文档从MS Word直接保存到云,并使用特定的数据库映射/逻辑

问题:

从Web应用程序下载MS Word文档(数据库id)时,我是否可以将唯一id(第122424-3213-23423行)插入其中

为什么我需要它(唯一id)

从MS Word更新文档时,我将使用此id映射/更新正确的文档


非常感谢您的帮助。

据我所知,您希望向Word文档中添加一些元数据

你可以用

通常,它是一个存储在文档中的字典(键/值),可以通过Word interop访问

假设您的属性名为“
DatabaseId

获取属性集合:

var props = (Office.DocumentProperties)app.ActiveDocument.CustomDocumentProperties
因此,使用此代码设置值:

props.Add("DatabaseId", false, Microsoft.Office.Core
            .MsoDocProperties.msoPropertyTypeString, "122424-3213-23423423");
获取值:

props["DatabaseId"].Value
服务器端代码(.NET核心) 当从Web应用程序下载任何MS Office文档时,我会将相应的数据库ID写入文档的元标记中。此ID有助于我在VSTO加载项中更新现有文档

提及

VSTO附加模块

public static string GetCustomMetaTagId(Document document)
    {
        Microsoft.Office.Core.DocumentProperties prps = (Microsoft.Office.Core.DocumentProperties)document.CustomDocumentProperties;

        string customId = "";

        try
        {
            customId  = prps != null && prps["CUSTOM-ID"] != null ? prps["CUSTOM-ID"].Value : "";
        }
        catch (Exception)
        {

        }

        return customId  ;
    }

不清楚你在想什么,这里?应该在什么时候将ID写入文档?你的问题是把它放在哪里?什么技术将进行更新(它将如何访问文档)?当然,请查看:
public static string GetCustomMetaTagId(Document document)
    {
        Microsoft.Office.Core.DocumentProperties prps = (Microsoft.Office.Core.DocumentProperties)document.CustomDocumentProperties;

        string customId = "";

        try
        {
            customId  = prps != null && prps["CUSTOM-ID"] != null ? prps["CUSTOM-ID"].Value : "";
        }
        catch (Exception)
        {

        }

        return customId  ;
    }