HOW TO

Programatically export a map document to a publisher (.pmf) file

Last Published: April 25, 2020

Summary

Instructions provide a sample code to export the current map document to a Publisher file (PMF) at a given location.

Procedure



  1. Start ArcMap.
  2. Select Tools > Extensions, check the box next to 'Publisher', and select Close to dismiss the dialog box.
  3. Open the Visual Basic Editor.

    In ArcMap, select Tools > Macros > Visual Basic Editor.

  4. In the Project Explorer window, expand Project.mxt and select ArcMap Objects > ThisDocument and right-click and select View Code.
    [O-Image] Visual Basic Project  Explorer
    Note:
    Code in the Project's ThisDocument code module will only run in the current map document. To store the code in all map documents, open the Normal.mxt > ThisDocument code module instead.

  5. Select Tools > References, and check the box next to 'ESRI Publisher Extension 1.0 Object Library'. Click OK.
  6. Paste the following code into the code module.

    Code:
    Dim testpub As String
    Dim pid As New UID
    Dim pIPMF As IPMF
    Dim pExtManager As IExtensionManager
    Dim pExt As IExtension

    testpub = "c:\temp\TestPub.pmf"

    'Set the publisher extension
    Set pExtManager = Application
    pid.Value = "{8AEE0DE1-535C-4788-95C8-1659444D4C02}"
    Set pExt = pExtManager.FindExtension(pid)

    Set pIPMF = pExt 'QI

    'Publish map document to location specified with testpub
    pIPMF.PMFPublish (testpub)

  7. Close the Visual Basic Editor.
  8. Run the code.

    A. Click Tools > Macros > Macros to display the Macros dialog box.
    B. Select a macro and click Run.

Article ID:000006329

Software:
  • ArcMap 8 x
  • ArcMap 9 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic