The code works perfectly. Make sure that you work in assembly environment and select a component before running this code.
Also, the code had quite many not used variables, which I deleted to simplify the macro:
If .GetSelectedObjectCount2(-1) <> 0 And .GetSelectedObjectType3(1, -1) <> 0 Then
Dim SourceURL As String
SourceURL = .GetSelectedObjectsComponent4(1, -1).GetModelDoc2.Extension.CustomPropertyManager("").Get("DrawnBy")
I just figured out the problem. Evidently, the problem is that indeed if the part is set to lightweight, the custom properties of that part are not made visible to the API.