Excel VBA Macro to display SharePoint Content Type Columns

Copper Contributor

Hi there, I am trying to use an Excel VBA macro to gather data from my SharePoint content type columns and display it in an excel spreadsheet.

 

When using the CompanyID function it returns the correct result. However, when I try to return the Title of the file it just returns 0. Is there anything I need to add or change within my code to fix this issue?

 

Function Title()
  Dim wb As Workbook
  Set wb = ThisWorkbook
  For Each prop In wb.ContentTypeProperties
    If prop.Name = "Title" Then
      Title = prop.Value
    End If
  Next prop
End Function
Function CompanyID()
  Dim wb As Workbook
  Set wb = ThisWorkbook
  For Each prop In wb.ContentTypeProperties
    If prop.Name = "CompanyID" Then
      CompanyID = prop.Value
    End If
  Next prop
End Function

 

Here is the 2 cells that are populated. I have used =Title() to call the title function and =CompanyID() to call the CompanyID Function.

EXCEL_BAgf2nTgOR.png

 

 

The expected outcome of the Name cell should be Testing instead of 0.

0 Replies