you will need to add a variable for the for the .PartDoc, so it would look like this:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swPart As SldWorks.PartDoc
Dim swMaterial As SldWorks.MaterialVisualPropertiesData
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swPart = swModel
Set swMaterial = swPart.GetMaterialVisualProperties()
swMaterial.RealView = True
Here is an example where that is used 2017 SOLIDWORKS API Help - Get and Set Material Visual Properties Example (VBA)
Hope this helps
Thank you so much Artem! That did the trick.
Why I couldn't find that when searched online is a mystery to me!