This sample illustrates how you can access a symbol stored in a style gallery. Typically, you would use it to symbolize a feature or geometry.
How to use
- Copy-paste the code from this sample into a module in the Visual Basic Editor.
- Click on View > Immediate Window if you do not already have the Immediate Window open.
- Run the procedure. Examine the output in the Immediate window.
Public Sub UseSymbolFromStyleGallery()
Dim pStyleStorage As IStyleGalleryStorage
Dim pStyleGallery As IStyleGallery
Dim pStyleClass As IStyleGalleryClass
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
Set pStyleGallery = pMxDoc.StyleGallery
Set pStyleStorage = pStyleGallery
Dim pEnumStyleGall As IEnumStyleGalleryItem
Dim pStyleItem As IStyleGalleryItem
Dim pMarkerSym As IMarkerSymbol
'Initialize the style gallery
Set pEnumStyleGall = pStyleGallery.Items("Marker Symbols", "ESRI.style", _
"Default")
pEnumStyleGall.Reset
Set pStyleItem = pEnumStyleGall.Next
Do While Not pStyleItem Is Nothing 'Loop through and access each marker
Set pMarkerSym = pStyleItem.Item
Debug.Print pStyleItem.Name & " " & pMarkerSym.Size
Set pStyleItem = pEnumStyleGall.Next
Loop
End Sub