protected override void OnClick()
        {
            //Enable publisher extension
            if (EnablePublisherExtension())
            {
                System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;

                IMxDocument mapDoc = ArcMap.Document;

                IPMFPublish3 publishMaps = new PublisherEngineClass();

                //Accept the default settings when the map is published.
                IPropertySet settings = publishMaps.GetDefaultPublisherSettings();              

                IArray orderedMaps = new ArrayClass();
                //Loop over all the maps in the map document and each one to an Array object
                for (int i = 0; i <= mapDoc.Maps.Count - 1; i++)
                {
                    orderedMaps.Add(mapDoc.Maps.get_Item(i));
                }

                try
                {
                    //Create the PMF file using the current settings and the map order specified in the IArray parameter
                    //It will be written to C:\\PublishedMap.pmf and the data will be referenced using relative paths.
                    publishMaps.PublishWithOrder(orderedMaps, mapDoc.PageLayout, mapDoc.ActiveView, settings,
                                                 true, "C:\\PublishedMap.pmf");


                    //Report outcome to the user
                    string mapdocTitle = ((IDocument)ArcMap.Document).Title;
                    string msg = string.Empty;

                    if (orderedMaps.Count == 1)
                    {
                        msg = "The map in " + mapdocTitle + " has been published successfully";
                    }
                    else
                    {
                        msg = "The maps in " + mapdocTitle + " have been published successfully";
                    }

                    MessageBox.Show(msg);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error Publishing Map: " + ex.Message, "Error");
                }

                System.Windows.Forms.Cursor.Current = Cursors.Default;

            }

            ArcMap.Application.CurrentTool = null;
        }
        protected override void OnClick()
        {
            //Enable publisher extension
            if (EnablePublisherExtension())
            {
                System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;

                IMxDocument mapDoc = ArcMap.Document;

                IPMFPublish3 publishMaps = new PublisherEngineClass();

                //Accept the default settings when the map is published.
                IPropertySet settings = publishMaps.GetDefaultPublisherSettings();

                IArray orderedMaps = new ArrayClass();
                //Loop over all the maps in the map document and each one to an Array object
                for (int i = 0; i <= mapDoc.Maps.Count - 1; i++)
                {
                    orderedMaps.Add(mapDoc.Maps.get_Item(i));
                }

                try
                {
                    //Create the PMF file using the current settings and the map order specified in the IArray parameter
                    //It will be written to C:\\PublishedMap.pmf and the data will be referenced using relative paths.
                    publishMaps.PublishWithOrder(orderedMaps, mapDoc.PageLayout, mapDoc.ActiveView, settings,
                                                 true, "C:\\PublishedMap.pmf");


                    //Report outcome to the user
                    string mapdocTitle = ((IDocument)ArcMap.Document).Title;
                    string msg         = string.Empty;

                    if (orderedMaps.Count == 1)
                    {
                        msg = "The map in " + mapdocTitle + " has been published successfully";
                    }
                    else
                    {
                        msg = "The maps in " + mapdocTitle + " have been published successfully";
                    }

                    MessageBox.Show(msg);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error Publishing Map: " + ex.Message, "Error");
                }

                System.Windows.Forms.Cursor.Current = Cursors.Default;
            }

            ArcMap.Application.CurrentTool = null;
        }