How to set the Sharepoint document type in an Excel file with VBA?

风格不统一 提交于 2020-02-23 07:31:25

问题


I'm creating an Excel file (.xlsb) each day and upload it manually to SharePoint. It always puts the file under document type 'Description' in SharePoint. But I want it under Document type 'Report'.

Does someone have a piece of VBA code that sets the SharePoint Document type to 'Report' (or any other doc type) in the newly created XLSB file?

I learned how to set a document property in an XLSB but I can't find the right property that does the trick for the SharePoint doc type. If I

  • change the files property in SharePoint (edit properties) and set the doc type to e.g. 'Report' (annoying)
  • download that file from SharePoint
  • change it, and...
  • upload it to SharePoint again, ...it'll put it into the right document type section in SharePoint

But as I create a new file every day I'd like to set the SharePoint doc type directly.

Any ideas?

update 14-Nov-2019: I gave it another shot and - HEY! - it works with...

Function setDocumentType()
Dim prop            As Object

    For Each prop In ThisWorkbook.ContentTypeProperties
        If prop.name = "Document Type" Then
            prop.Value = "JoesTestDocType"
        End If
    Next prop
End Function

... as a first attempt. Or ...

ThisWorkbook.ContentTypeProperties.Item("Document Type") = "JoesDocType"

来源:https://stackoverflow.com/questions/55965295/how-to-set-the-sharepoint-document-type-in-an-excel-file-with-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!