Get a Symbol from the Style Gallery


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:
  1. Copy-paste the code from this sample into a module in the Visual Basic Editor.
  2. Click on View > Immediate Window if you do not already have the Immediate Window open.
  3. 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", "", _
  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
End Sub