使用 VBA 设置共享点标签/属性

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19449653/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 23:54:05  来源:igfitidea点击:

Set Sharepoint Tags/Properies with VBA

excelvbasharepoint

提问by Niall

Is it possible to set the Tags of a Sharepoint document (specifically Excel) using VBA. At present the only way I know to handle this is to save a file to Sharepoint, set the Tags when prompted, nd then download this file again and use it as a template.

是否可以使用 VBA 设置 Sharepoint 文档(特别是 Excel)的标签。目前,我知道处理此问题的唯一方法是将文件保存到 Sharepoint,在出现提示时设置标签,然后再次下载此文件并将其用作模板。

However, I need to work with several different permuations of these Tags and it's a major pain having to create a separate template for each one, especially if you then need to amend the template, and have to replicate those amendments 10s of times.

但是,我需要处理这些标签的几种不同排列,并且必须为每个标签创建单独的模板是一个主要的痛苦,特别是如果您随后需要修改模板,并且必须重复这些修改 10 次。

So is it possible to do this via VBA? I've tried recording a macro whilst I set them and it doesn't record anything regarding the Tags

那么是否可以通过 VBA 来做到这一点?我尝试在设置宏的同时录制宏,但它没有记录任何有关标签的内容

回答by Franco Rondini

As far as I know , we can set the Tags of an Excel documentin VBAbefore it gets uploaded onto a Sharepoint library, by settings values for the

据我所知,我们可以在VBA 中设置Excel 文档的标签,然后再将其上传到 Sharepoint 库,通过设置

Workbook.ContentTypeProperties

For example:

例如:

 ActiveWorkbook.ContentTypeProperties("Line of Business").Value = pLine
 ActiveWorkbook.ContentTypeProperties("Company Name").Value = pCompany
 ActiveWorkbook.ContentTypeProperties("Year").Value = pYear

I'd link some readings to learn more: It might be useful:[John Chapman's SharePoint Blog: Update SharePoint Document Property from Excel VBA]

我会链接一些阅读材料以了解更多信息:它可能有用:[John Chapman 的 SharePoint 博客:从 Excel VBA 更新 SharePoint 文档属性]

http://www.sharepointjohn.com/sharepoint-2007-–-update-sharepoint-document-property-from-excel-vba/

http://www.sharepointjohn.com/sharepoint-2007---update-sharepoint-document-property-from-excel-vba/

Please note that there are some troubles with certain types of property: see Setting Custom Document properties that will be used in Sharepointand this thread

请注意,某些类型的属性存在一些问题:请参阅 设置将在 Sharepoint 中使用的自定义文档属性此线程

回答by MStigge

I had the same problem. The workaround I used was as follows

我有同样的问题。我使用的解决方法如下

On Error Resume Next
Application.DisplayAlerts = False
ThisWorkbook.SaveAs Pth
ThisWorkbook.ContentTypeProperties("Report Type").Value = "BranchManagement"
ThisWorkbook.SaveAs Pth
Workbooks(ThisWorkbook.Name).CheckIn
Application.DisplayAlerts = True
On Error GoTo 0

In my case I also had to check the book in after getting it saved. Hope this helps!

在我的情况下,我还必须在保存后签入这本书。希望这可以帮助!