使用Excel VBA在线将元数据值写入SharePoint在线-不同的问题

时间:2019-01-11 20:04:20

标签: excel vba sharepoint metadata sharepoint-online

我在Excel 2016中有一个VBA宏,用于将表单保存到SharePoint Online。我需要它使用ContentTypeProperties填充SP文档库中的几个元数据值。当要保存的文档是Excel时,我可以执行此操作,但是我正在使用Excel文件来生成PDF并将其保存到SharePoint,但是我没有找到如何用PDF填充这些元数据值。如果我上传Excel,它们就在那里。有了PDF,事实并非如此。这是宏:

Sub SubmitButton_click()
    'SUBMIT APPROVAL button event

    Dim FileSaveInfo As Variant
    Dim SPPath As String
    Dim POName As String
    Dim FullNamePath As String

    'Initialize naming
    SPPath = "https://mycompany.sharepoint.com/sites/Finance/Purchase%20Orders/"
    POName = "PO" & Cells(10, 9).Value & "_"
    POName = POName & Format(Now(), "yyyyMMddHHmm") & ".pdf"
    FullNamePath = SPPath & POName

    'Set SharePoint metadata properties
    With ActiveWorkbook
        .ContentTypeProperties("Level 1 Approver").Value = Cells(11, 14).Value
        .ContentTypeProperties("Level 2 Approver").Value = Cells(12, 14).Value
    End With

    'Upload to SharePoint as PDF
    ActiveSheet.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:=FullNamePath, _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        From:=1, To:=1, _
        OpenAfterPublish:=False

End Sub

感谢任何想法。

0 个答案:

没有答案