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
- Run ArcMap and Open a map with at least one bookmark.
- Add a custom UIToolControl to ArcMap.
- Click ArcMap Tools menu and click Customize...
- On the Customize dialog click the Commands tab.
- Click UIControls in the Categories list box.
- Click New UIControl button and create a UIButtonControl.
- Select the UIButtonControl from the Commands list box and drag it onto an ArcMap Toolbar.
- Right click the UIButtonControl on the toolbar and click View Source.
- Paste the code between the UIButtonControl_Click and End Sub lines.
- 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
- Close VBA
- Click the Custom Button you added and the bookmarks will be published to separate published maps.
'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