<?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 Formatting Strings and Exporting to MS Word in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/formatting-strings-and-exporting-to-ms-word/m-p/15937#M1240</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey, does anyone know how to bold a string that you are writing to an MS word doc? I am using the win32com.cleint module and none of the syntaxes seem to work (ie HTML tags, setting bold variables, etc) The help on this module is terrible on the internet.... See comment in the code for where I would like the bold text string.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; wordapp = win32com.client.Dispatch("Word.Application") # Create new Word Object
&amp;nbsp;&amp;nbsp;&amp;nbsp; wordapp.Visible = 0 # Word Application should`t be visible
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc = wordapp.Documents.Add() # Create new Document Object
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.PageSetup.Orientation = 1 # Make some Setup to the Document:
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.PageSetup.LeftMargin = 20
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.PageSetup.TopMargin = 20
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.PageSetup.BottomMargin = 20
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.PageSetup.RightMargin = 20
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.Content.Font.Size = 10
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.Content.Paragraphs.TabStops.Add (100)
&amp;nbsp;&amp;nbsp;&amp;nbsp; # I would like to bold the last concatenated string..."The number of ObjectID records copied....."
&amp;nbsp;&amp;nbsp;&amp;nbsp; if tifCounter2 &amp;lt; tifCounter:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.Content.Text = "Number of Photo Files on the S:drive = " + str(tifCounter) + '\n' + "Number of Ecosite_P records that have an associated ObjectID record = " + str(counter) + '\n' + "Number of Photos copied to new Folder = " + str(tifCounter2) + '\n' + "The number of ObjectID records copied to the new folder does not match the records in the feature class. Please review"
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.Content.Text = "Number of Photo Files on the S:drive = " + str(tifCounter) + '\n' + "Number of records that have an associated ObjectID record = " + str(counter) + '\n' + "Number of files copied to new Folder = " + str(tifCounter2) + '\n'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.Content.MoveEnd
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.Close() # Close the Word Document (a save-Dialog pops up)
&amp;nbsp;&amp;nbsp;&amp;nbsp; wordapp.Quit() # Close the Word Application


&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Jun 2011 16:33:50 GMT</pubDate>
    <dc:creator>MikeMacRae</dc:creator>
    <dc:date>2011-06-21T16:33:50Z</dc:date>
    <item>
      <title>Formatting Strings and Exporting to MS Word</title>
      <link>https://community.esri.com/t5/python-questions/formatting-strings-and-exporting-to-ms-word/m-p/15937#M1240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey, does anyone know how to bold a string that you are writing to an MS word doc? I am using the win32com.cleint module and none of the syntaxes seem to work (ie HTML tags, setting bold variables, etc) The help on this module is terrible on the internet.... See comment in the code for where I would like the bold text string.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; wordapp = win32com.client.Dispatch("Word.Application") # Create new Word Object
&amp;nbsp;&amp;nbsp;&amp;nbsp; wordapp.Visible = 0 # Word Application should`t be visible
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc = wordapp.Documents.Add() # Create new Document Object
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.PageSetup.Orientation = 1 # Make some Setup to the Document:
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.PageSetup.LeftMargin = 20
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.PageSetup.TopMargin = 20
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.PageSetup.BottomMargin = 20
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.PageSetup.RightMargin = 20
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.Content.Font.Size = 10
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.Content.Paragraphs.TabStops.Add (100)
&amp;nbsp;&amp;nbsp;&amp;nbsp; # I would like to bold the last concatenated string..."The number of ObjectID records copied....."
&amp;nbsp;&amp;nbsp;&amp;nbsp; if tifCounter2 &amp;lt; tifCounter:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.Content.Text = "Number of Photo Files on the S:drive = " + str(tifCounter) + '\n' + "Number of Ecosite_P records that have an associated ObjectID record = " + str(counter) + '\n' + "Number of Photos copied to new Folder = " + str(tifCounter2) + '\n' + "The number of ObjectID records copied to the new folder does not match the records in the feature class. Please review"
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.Content.Text = "Number of Photo Files on the S:drive = " + str(tifCounter) + '\n' + "Number of records that have an associated ObjectID record = " + str(counter) + '\n' + "Number of files copied to new Folder = " + str(tifCounter2) + '\n'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.Content.MoveEnd
&amp;nbsp;&amp;nbsp;&amp;nbsp; worddoc.Close() # Close the Word Document (a save-Dialog pops up)
&amp;nbsp;&amp;nbsp;&amp;nbsp; wordapp.Quit() # Close the Word Application


&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jun 2011 16:33:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/formatting-strings-and-exporting-to-ms-word/m-p/15937#M1240</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2011-06-21T16:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Strings and Exporting to MS Word</title>
      <link>https://community.esri.com/t5/python-questions/formatting-strings-and-exporting-to-ms-word/m-p/15938#M1241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There is a good description of programming Word in Python in "Python programming on Win32" by Mark Hammond (O'Reilly) and I found some specific hints in "Writing Excel Macros with VBA" by Roman (O'Reily).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Quote from Mark &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;Please note: Word is hard to work with.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here are some examples from his book:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://examples.oreilly.com/9781565926219"&gt;http://examples.oreilly.com/9781565926219&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2011 04:21:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/formatting-strings-and-exporting-to-ms-word/m-p/15938#M1241</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2011-06-22T04:21:39Z</dc:date>
    </item>
  </channel>
</rss>

