Coding issue with XML for word document

accessnewbie at gmail.com accessnewbie at gmail.com
Mon Feb 6 20:00:25 EST 2017


I am constructing a sentence to insert into a word xml template. My code is below

------------------------
#Create a list

if len(myList) > 0:
    if len(myList) > 1:
        testText = list_format(myList) + " dealers."
    else:
        myText = myList[0] + " dealer."

#Contruct sentence

    #myBlurb = "<w:cr/><w:r><w:rPr><w:b/></w:rPr><w:t>My Favorite Cars - </w:t></w:r><w:r><w:t> My favorite cars are available at </w:t></w:r>"  + myText + "<w:cr/>"
    myBlurb = "<w:cr/>My Favorite Cars - My favorite cars are available at " + myText + "<w:cr/>"
else:
    myBlurb = ""


-------------------------------------------

If a list exists (not = 0) Then

I am trying to get the following output:

My Favorite Cars - My favorite cars are available at (list of dealers) dealers.

There is a newline above and below this line. The first three words and the dash are bold. All other words are regular.

This works

myBlurb = "<w:cr/>My Favorite Cars - My favorite cars are available at " + myText + "<w:cr/>"

But when I try to bold, it bombs. It does not seem to like either of these (+ myText + "<w:cr/>") (separately or together) appended on the end.

Thia does not work

myBlurb = "<w:cr/><w:r><w:rPr><w:b/></w:rPr><w:t>My Favorite Cars - </w:t></w:r><w:r><w:t> My favorite cars are available at </w:t></w:r>"  + myText + "<w:cr/>

What am I missing here?



More information about the Python-list mailing list