BrokenLegMike

Formatting Strings and Exporting to MS Word

Discussion created by BrokenLegMike on Jun 21, 2011
Latest reply on Jun 21, 2011 by kimo
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.


    wordapp = win32com.client.Dispatch("Word.Application") # Create new Word Object
    wordapp.Visible = 0 # Word Application should`t be visible
    worddoc = wordapp.Documents.Add() # Create new Document Object
    worddoc.PageSetup.Orientation = 1 # Make some Setup to the Document:
    worddoc.PageSetup.LeftMargin = 20
    worddoc.PageSetup.TopMargin = 20
    worddoc.PageSetup.BottomMargin = 20
    worddoc.PageSetup.RightMargin = 20
    worddoc.Content.Font.Size = 10
    worddoc.Content.Paragraphs.TabStops.Add (100)
    # I would like to bold the last concatenated string..."The number of ObjectID records copied....."
    if tifCounter2 < tifCounter:
        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"
    else:
        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'
        
    worddoc.Content.MoveEnd
    worddoc.Close() # Close the Word Document (a save-Dialog pops up)
    wordapp.Quit() # Close the Word Application


Outcomes