How to publish each bookmark to individual published maps


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. Run ArcMap and Open a map with at least one bookmark.
  2. Add a custom UIToolControl to ArcMap.
  3. Click ArcMap Tools menu and click Customize...
  4. On the Customize dialog click the Commands tab.
  5. Click UIControls in the Categories list box.
  6. Click New UIControl button and create a UIButtonControl.
  7. Select the UIButtonControl from the Commands list box and drag it onto an ArcMap Toolbar.
  8. Right click the UIButtonControl on the toolbar and click View Source.
  9. Paste the code between the UIButtonControl_Click and End Sub lines.
  10. Click Tool menu references and check ESRI Publisher Object Library, ESRI PublisherUI Object Library, ESRI Carto Object Library, ESRI System Object Library, ESRI ArcMap Object Library and ESRI ArcMapUI Object Library
  11. Close VBA
  12. Click the Custom Button you added and the bookmarks will be published to separate published maps.
[VBA]
'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 ISpatialBookmark
Set pAOIBookmark = pEnumSpatialBookmarks.Next

Do Until (pAOIBookmark Is Nothing)
    pAOIBookmark.ZoomTo pMxDocument.FocusMap
    'Note the hardcoded path.  This is the location the published map(s) will be written to.
    'Change this to an appropriate path for your computer.
    pExtension.PMFPublish "c:\arcreaderproject\output\bm" & pAOIBookmark.Name & ".pmf"
    
    Set pAOIBookmark = pEnumSpatialBookmarks.Next
Loop