Publish Bookmarks

Created:7/25/2002
Description:

The following code shows you how to access the publisher extension in VBA, set publisher settings and publish map document bookmarks to separate published map files (PMF).

How to use:
  1. Open a map document with at least one bookmark.
  2. Copy-paste this procedure into ArcMap's VBA Editor.
  3. In the VBA Editor click Tools -> References and check ESRI Publisher Extension 1.0 Object Library.
  4. Run the procedure.
Private Sub UIButtonControl2_Click()

  'Sample that publishes the bookmarks of the active data frame to
  'separate .pmf files using the bookmark as the name for the published
  'map.  Publisher extension must be installed and a publisher license is needed.
  
  'Prep the map
  Dim pMxDocument As IMxDocument
  Set pMxDocument = ThisDocument
  
  'Set up the publisher
  Dim pExtension As IPMF
  Dim pUID As IUID
  Set pUID = New UID
  pUID.Value = "{8AEE0DE1-535C-4788-95C8-1659444D4C02}"
  Set pExtension = Application.FindExtensionByCLSID(pUID)
  
  'Example of a using a publisher settings.
  'Do not show the TOC in ArcReader
  pExtension.PMFSettings.SetProperty "ViewTOC", False
  
  'Open the map in Layout view
  pExtension.PMFSettings.SetProperty "DefaultViewType", esriAPEViewTypeLayoutOnly
  
  'Go through each bookmark in the map and publish it.
  Dim pMapBookmarks As IMapBookmarks
  Set pMapBookmarks = pMxDocument.focusMap
  
  Dim pEnumSpatialBookmarks As IEnumSpatialBookmark
  Set pEnumSpatialBookmarks = pMapBookmarks.Bookmarks
  pEnumSpatialBookmarks.Reset
  
  Dim pAOIBookmark As IAOIBookmark
  Set pAOIBookmark = pEnumSpatialBookmarks.Next
  
  Do Until (pAOIBookmark Is Nothing)
    pAOIBookmark.ZoomTo pMxDocument.focusMap
    pExtension.PMFPublish "c:\arcreaderproject\output\bm" & pAOIBookmark.name & ".pmf"
    
    Set pAOIBookmark = pEnumSpatialBookmarks.Next
  Loop
End Sub