<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Automating an Export of a Report in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/520917#M40833</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it an indent issue (not sure if it's just the Geonet forum formatting or if it's how you have it in your code)?&amp;nbsp; There doesn't appear to be a required indent after your if statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;Change this&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for lyr in arcpy.mapping.ListLayers(mxd,"",df):&amp;nbsp; 
&amp;nbsp; if lyr.name == "Concerns":&amp;nbsp; 
&amp;nbsp; arcpy.mapping.ExportReport(lyr,r"C:\ESRITest\NewGeoReportingSystem\GRS_GeneralReport.rlf",r"C:\ESRITest\NewGeoReportingSystem\GeneralReport.pdf") &lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="string"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;To this&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for lyr in arcpy.mapping.ListLayers(mxd,"",df):&amp;nbsp; 
&amp;nbsp; if lyr.name == "Concerns":&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportReport(lyr,r"C:\ESRITest\NewGeoReportingSystem\GRS_GeneralReport.rlf",r"C:\ESRITest\NewGeoReportingSystem\GeneralReport.pdf") &lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="string"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 22:43:27 GMT</pubDate>
    <dc:creator>JamesCrandall</dc:creator>
    <dc:date>2021-12-11T22:43:27Z</dc:date>
    <item>
      <title>Automating an Export of a Report</title>
      <link>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/520916#M40832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The goal is run a report via python script periodically via a scheduled task. If there is a better method for scheduling I am all ears, but the crux of my issue is getting the python script to run outside of ArcMap.&amp;nbsp; It runs fine within ArcMap, but as a standalone script it throws errors.&amp;nbsp; Below is my code and an image of what errors it giving me.&amp;nbsp; Any help is much appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import sys&amp;nbsp; 
import traceback&amp;nbsp; 
mxd = arcpy.mapping.MapDocument(r"C:\ESRITest\NewGeoReportingSystem\GeoReportingGC.mxd")
try:
&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd)[0]
&amp;nbsp; for lyr in arcpy.mapping.ListLayers(mxd,"",df):
&amp;nbsp; if lyr.name == "Concerns":
&amp;nbsp; arcpy.mapping.ExportReport(lyr,r"C:\ESRITest\NewGeoReportingSystem\GRS_GeneralReport.rlf",r"C:\ESRITest\NewGeoReportingSystem\GeneralReport.pdf")
except arcpy.ExecuteError:&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get the tool error messages&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; msgs = arcpy.GetMessages(2)&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Return tool error messages for use with a script tool&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(msgs)&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Print tool error messages for use in Python/PythonWin&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print msgs&amp;nbsp; 

except:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get the traceback object&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; tb = sys.exc_info()[2]&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; tbinfo = traceback.format_tb(tb)[0]&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Concatenate information together concerning the error into a message string&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Return python error messages for use in script tool or Python Window&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(pymsg)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(msgs)&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Print Python error messages for use in Python / Python Window&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print pymsg + "\n"&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print msgs&amp;nbsp; 
finally:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; del mxd

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="PythonQuestion.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/190546_PythonQuestion.png" style="width: 620px; height: 314px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:43:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/520916#M40832</guid>
      <dc:creator>DavidBuehler</dc:creator>
      <dc:date>2021-12-11T22:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Automating an Export of a Report</title>
      <link>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/520917#M40833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it an indent issue (not sure if it's just the Geonet forum formatting or if it's how you have it in your code)?&amp;nbsp; There doesn't appear to be a required indent after your if statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;Change this&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for lyr in arcpy.mapping.ListLayers(mxd,"",df):&amp;nbsp; 
&amp;nbsp; if lyr.name == "Concerns":&amp;nbsp; 
&amp;nbsp; arcpy.mapping.ExportReport(lyr,r"C:\ESRITest\NewGeoReportingSystem\GRS_GeneralReport.rlf",r"C:\ESRITest\NewGeoReportingSystem\GeneralReport.pdf") &lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="string"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;To this&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for lyr in arcpy.mapping.ListLayers(mxd,"",df):&amp;nbsp; 
&amp;nbsp; if lyr.name == "Concerns":&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportReport(lyr,r"C:\ESRITest\NewGeoReportingSystem\GRS_GeneralReport.rlf",r"C:\ESRITest\NewGeoReportingSystem\GeneralReport.pdf") &lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="string"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:43:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/520917#M40833</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T22:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Automating an Export of a Report</title>
      <link>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/520918#M40834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi James,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it just how it came across in Geonet.&amp;nbsp; I did have it indented. Any other thoughts?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2016 20:44:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/520918#M40834</guid>
      <dc:creator>DavidBuehler</dc:creator>
      <dc:date>2016-03-10T20:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: Automating an Export of a Report</title>
      <link>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/520919#M40835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;include the mapping module?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy.mapping&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Probably not the issue.&amp;nbsp; Maybe have a look at this &lt;A href="http://gis.stackexchange.com/questions/54642/has-anybody-used-arcpy-mapping-exportreport-successfully-on-64bit-machine" title="http://gis.stackexchange.com/questions/54642/has-anybody-used-arcpy-mapping-exportreport-successfully-on-64bit-machine"&gt;arcgis 10.1 - Has anybody used arcpy.mapping.ExportReport successfully on 64bit machine? - Geographic Information System…&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2016 21:09:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/520919#M40835</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-03-10T21:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: Automating an Export of a Report</title>
      <link>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/520920#M40836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you seen &lt;A href="https://community.esri.com/thread/72221"&gt;Arcpy Export report error&lt;/A&gt;?&lt;A href="https://community.esri.com/migrated-users/39858"&gt;Jeffrey May&lt;/A&gt;​ says:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;I did learn that ExportReport will not support background processing and it did not seems to like being a part of a stand alone Python script either.&amp;nbsp; I was able to execute this funtion by turning off background processing and running the script via a ArcMap Script Tool. &lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Doesn't seem to help your case since you want to launch a scheduled task... but just noting others have had similar issues.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2016 21:22:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/520920#M40836</guid>
      <dc:creator>ChrisSmith7</dc:creator>
      <dc:date>2016-03-10T21:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: Automating an Export of a Report</title>
      <link>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/520921#M40837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually it does help.&amp;nbsp; I was digging and digging and I found what both you and James are talking about.&amp;nbsp; It is a 32-bit vs 64-bit issue.&amp;nbsp; What I did to solve the problem was just tell the scheduled task to use the 32-bit version as the program to launch, and pointed it to the .py file.&amp;nbsp; It worked like a charm. Now if I can figure out how to make it use the 32-bit version from inside the script and do a few more things, I will be all set.&amp;nbsp; Thanks both of you for your help, and pointing me in the right direction.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2016 21:33:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/520921#M40837</guid>
      <dc:creator>DavidBuehler</dc:creator>
      <dc:date>2016-03-10T21:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: Automating an Export of a Report</title>
      <link>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/520922#M40838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;James,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found that very same link, and was reading it over.&amp;nbsp; That is the issue.&amp;nbsp; 32-bit vs 64-bit. I solved it by just telling the task scheduler to fun the 32-bit version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2016 21:44:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/520922#M40838</guid>
      <dc:creator>DavidBuehler</dc:creator>
      <dc:date>2016-03-10T21:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: Automating an Export of a Report</title>
      <link>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/1007785#M59234</link>
      <description>&lt;P&gt;Does anyone know if this has been resolved? I need to use ExportReport in an mxd. I have been narrowing down reasons why it would fail (network drive, bad path strings, etc) and it just won't open the rlf.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2020 18:05:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automating-an-export-of-a-report/m-p/1007785#M59234</guid>
      <dc:creator>DanDeegan</dc:creator>
      <dc:date>2020-12-08T18:05:46Z</dc:date>
    </item>
  </channel>
</rss>

