Reputation: 33
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 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
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
Here is the 2 cells that are populated. I have used =Title() to call the title function and =CompanyID() to call the CompanyID Function.
The expected outcome of the Name cell should be Testing instead of 0.
Upvotes: 0
Views: 114
Reputation: 33
I tested if the issue was a string related issue or an issue with using the "Title" property and when I created a separate column in my content type and entered a string this worked fine. So I decided to change my code specifically for getting the Title and used the following code which I found online after doing some research.
Function DocProp(Info_needed As String) As Variant
Application.Volatile
DocProp = ThisWorkbook.BuiltinDocumentProperties(Info_needed).Value
End Function
Upvotes: 1