Package parasol :: Module Word_wrapper
[hide private]
[frames] | no frames]

Source Code for Module parasol.Word_wrapper

  1  import win32com 
  2  from win32com.client import Dispatch 
  3  import string 
  4   
  5  # include word constants here 
  6  wdNormalView                  =0x1        # from enum WdViewType 
  7  wdStyleTypeTable              =0x3        # from enum WdStyleType 
  8  wdAutoFitContent              =0x1        # from enum WdAutoFitBehavior 
  9  wdAutoFitFixed                =0x0        # from enum WdAutoFitBehavior 
 10  wdAutoFitWindow               =0x2        # from enum WdAutoFitBehavior 
 11  wdWord8TableBehavior          =0x0        # from enum WdDefaultTableBehavior 
 12  wdWord9TableBehavior          =0x1        # from enum WdDefaultTableBehavior 
 13   
 14  wdAlignRowCenter              =0x1        # from enum WdRowAlignment 
 15  wdAlignRowLeft                =0x0        # from enum WdRowAlignment 
 16  wdAlignRowRight               =0x2        # from enum WdRowAlignment 
 17   
 18  justDict = {'c':wdAlignRowCenter, 'l':wdAlignRowLeft, 'r':wdAlignRowRight } 
 19   
 20  wdLineStyleNone               =0x0        # from enum WdLineStyle 
 21  wdBorderBottom                =-3         # from enum WdBorderType 
 22  wdBorderDiagonalDown          =-7         # from enum WdBorderType 
 23  wdBorderDiagonalUp            =-8         # from enum WdBorderType 
 24  wdBorderHorizontal            =-5         # from enum WdBorderType 
 25  wdBorderLeft                  =-2         # from enum WdBorderType 
 26  wdBorderRight                 =-4         # from enum WdBorderType 
 27  wdBorderTop                   =-1         # from enum WdBorderType 
 28  wdBorderVertical              =-6         # from enum WdBorderType 
 29   
 30  # for text color index 
 31  wdAuto                        =0x0        # from enum WdColorIndex 
 32  wdBlack                       =0x1        # from enum WdColorIndex 
 33  wdBlue                        =0x2        # from enum WdColorIndex 
 34  wdBrightGreen                 =0x4        # from enum WdColorIndex 
 35  wdByAuthor                    =-1         # from enum WdColorIndex 
 36  wdDarkBlue                    =0x9        # from enum WdColorIndex 
 37  wdDarkRed                     =0xd        # from enum WdColorIndex 
 38  wdDarkYellow                  =0xe        # from enum WdColorIndex 
 39  wdGray25                      =0x10       # from enum WdColorIndex 
 40  wdGray50                      =0xf        # from enum WdColorIndex 
 41  wdGreen                       =0xb        # from enum WdColorIndex 
 42  wdNoHighlight                 =0x0        # from enum WdColorIndex 
 43  wdPink                        =0x5        # from enum WdColorIndex 
 44  wdRed                         =0x6        # from enum WdColorIndex 
 45  wdTeal                        =0xa        # from enum WdColorIndex 
 46  wdTurquoise                   =0x3        # from enum WdColorIndex 
 47  wdViolet                      =0xc        # from enum WdColorIndex 
 48  wdWhite                       =0x8        # from enum WdColorIndex 
 49  wdYellow                      =0x7        # from enum WdColorIndex 
 50   
 51  textColorIndexDict = {'auto':wdAuto ,'k':wdBlack ,'b':wdBlue ,'gg':wdBrightGreen , 
 52      'auth':wdByAuthor ,'bb':wdDarkBlue ,'rr':wdDarkRed ,'yy':wdDarkYellow , 
 53      '25':wdGray25 ,'50':wdGray50 ,'g':wdGreen ,'no':wdNoHighlight ,'p':wdPink , 
 54      'r':wdRed ,'t':wdTeal ,'q':wdTurquoise ,'v':wdViolet ,'w':wdWhite , 
 55      'y':wdYellow } 
 56   
 57  # for color definitions 
 58  if 1: 
 59          wdColorAqua                   =0xcccc33   # from enum WdColor 
 60          wdColorAutomatic              =-16777216  # from enum WdColor 
 61          wdColorBlack                  =0x0        # from enum WdColor 
 62          wdColorBlue                   =0xff0000   # from enum WdColor 
 63          wdColorBlueGray               =0x996666   # from enum WdColor 
 64          wdColorBrightGreen            =0xff00     # from enum WdColor 
 65          wdColorBrown                  =0x3399     # from enum WdColor 
 66          wdColorDarkBlue               =0x800000   # from enum WdColor 
 67          wdColorDarkGreen              =0x3300     # from enum WdColor 
 68          wdColorDarkRed                =0x80       # from enum WdColor 
 69          wdColorDarkTeal               =0x663300   # from enum WdColor 
 70          wdColorDarkYellow             =0x8080     # from enum WdColor 
 71          wdColorGold                   =0xccff     # from enum WdColor 
 72          wdColorGray05                 =0xf3f3f3   # from enum WdColor 
 73          wdColorGray10                 =0xe6e6e6   # from enum WdColor 
 74          wdColorGray125                =0xe0e0e0   # from enum WdColor 
 75          wdColorGray15                 =0xd9d9d9   # from enum WdColor 
 76          wdColorGray20                 =0xcccccc   # from enum WdColor 
 77          wdColorGray25                 =0xc0c0c0   # from enum WdColor 
 78          wdColorGray30                 =0xb3b3b3   # from enum WdColor 
 79          wdColorGray35                 =0xa6a6a6   # from enum WdColor 
 80          wdColorGray375                =0xa0a0a0   # from enum WdColor 
 81          wdColorGray40                 =0x999999   # from enum WdColor 
 82          wdColorGray45                 =0x8c8c8c   # from enum WdColor 
 83          wdColorGray50                 =0x808080   # from enum WdColor 
 84          wdColorGray55                 =0x737373   # from enum WdColor 
 85          wdColorGray60                 =0x666666   # from enum WdColor 
 86          wdColorGray625                =0x606060   # from enum WdColor 
 87          wdColorGray65                 =0x595959   # from enum WdColor 
 88          wdColorGray70                 =0x4c4c4c   # from enum WdColor 
 89          wdColorGray75                 =0x404040   # from enum WdColor 
 90          wdColorGray80                 =0x333333   # from enum WdColor 
 91          wdColorGray85                 =0x262626   # from enum WdColor 
 92          wdColorGray875                =0x202020   # from enum WdColor 
 93          wdColorGray90                 =0x191919   # from enum WdColor 
 94          wdColorGray95                 =0xc0c0c    # from enum WdColor 
 95          wdColorGreen                  =0x8000     # from enum WdColor 
 96          wdColorIndigo                 =0x993333   # from enum WdColor 
 97          wdColorLavender               =0xff99cc   # from enum WdColor 
 98          wdColorLightBlue              =0xff6633   # from enum WdColor 
 99          wdColorLightGreen             =0xccffcc   # from enum WdColor 
100          wdColorLightOrange            =0x99ff     # from enum WdColor 
101          wdColorLightTurquoise         =0xffffcc   # from enum WdColor 
102          wdColorLightYellow            =0x99ffff   # from enum WdColor 
103          wdColorLime                   =0xcc99     # from enum WdColor 
104          wdColorOliveGreen             =0x3333     # from enum WdColor 
105          wdColorOrange                 =0x66ff     # from enum WdColor 
106          wdColorPaleBlue               =0xffcc99   # from enum WdColor 
107          wdColorPink                   =0xff00ff   # from enum WdColor 
108          wdColorPlum                   =0x663399   # from enum WdColor 
109          wdColorRed                    =0xff       # from enum WdColor 
110          wdColorRose                   =0xcc99ff   # from enum WdColor 
111          wdColorSeaGreen               =0x669933   # from enum WdColor 
112          wdColorSkyBlue                =0xffcc00   # from enum WdColor 
113          wdColorTan                    =0x99ccff   # from enum WdColor 
114          wdColorTeal                   =0x808000   # from enum WdColor 
115          wdColorTurquoise              =0xffff00   # from enum WdColor 
116          wdColorViolet                 =0x800080   # from enum WdColor 
117          wdColorWhite                  =0xffffff   # from enum WdColor 
118          wdColorYellow                 =0xffff     # from enum WdColor 
119   
120   
121  colorDict = {'a':wdColorAqua , 'auto':wdColorAutomatic , 'k':wdColorBlack , 'b':wdColorBlue ,  
122      'bg':wdColorBlueGray , 'gg':wdColorBrightGreen ,  
123      'brn':wdColorBrown , 'db':wdColorDarkBlue ,  
124      'dg':wdColorDarkGreen , 'dr':wdColorDarkRed ,  
125      'dt':wdColorDarkTeal , 'dy':wdColorDarkYellow ,  
126      'gold':wdColorGold , '05':wdColorGray05 , '10':wdColorGray10 , '125':wdColorGray125 ,  
127      '15':wdColorGray15 , '20':wdColorGray20 , '25':wdColorGray25 , '30':wdColorGray30 ,  
128      '35':wdColorGray35 , '375':wdColorGray375 , '40':wdColorGray40 , '45':wdColorGray45 ,  
129      '50':wdColorGray50 , '55':wdColorGray55 , '60':wdColorGray60 , '625':wdColorGray625 ,  
130      '65':wdColorGray65 , '70':wdColorGray70 , '75':wdColorGray75 , '80':wdColorGray80 ,  
131      '85':wdColorGray85 , '875':wdColorGray875 , '90':wdColorGray90 , '95':wdColorGray95 ,  
132      'g':wdColorGreen , 'i':wdColorIndigo , 'l':wdColorLavender , 'lb':wdColorLightBlue ,  
133      'lg':wdColorLightGreen , 'lo':wdColorLightOrange ,  
134      'lt':wdColorLightTurquoise , 'ly':wdColorLightYellow ,  
135      'lime':wdColorLime , 'olive':wdColorOliveGreen ,  
136      'o':wdColorOrange , 'pb':wdColorPaleBlue ,  
137      'p':wdColorPink , 'plum':wdColorPlum ,  
138      'r':wdColorRed , 'rose':wdColorRose , 'sea':wdColorSeaGreen ,  
139      'sky':wdColorSkyBlue , 'tan':wdColorTan , 't':wdColorTeal , 'q':wdColorTurquoise ,  
140      'v':wdColorViolet , 'w':wdColorWhite , 'y':wdColorYellow } 
141   
142   
143 -class WordWrap:
144 """Wrapper around Word documents to make them easy to build. 145 Has variables for the Applications, Document and Selection; 146 most methods add things at the end of the document"""
147 - def __init__(self, templatefile=None):
148 self.wordApp = Dispatch('Word.Application') 149 if templatefile == None: 150 self.wordDoc = self.wordApp.Documents.Add() 151 else: 152 self.wordDoc = self.wordApp.Documents.Add( Template=templatefile) 153 #set up the selection 154 self.wordDoc.Range(0,0).Select() 155 self.wordSel = self.wordApp.Selection
156 #fetch the styles in the document - see below 157 #self.getStyleDictionary() 158
159 - def show(self):
160 # convenience when developing 161 self.wordApp.Visible = 1
162
163 - def showFastView(self):
164 self.wordApp.Visible = 1 165 self.wordApp.Windows(1).View.Type = wdNormalView 166 self.wordApp.Options.Pagination = False
167 #self.wordApp.ScreenUpdating = False 168
169 - def setFastOptions(self):
170 self.wordApp.Visible = 0 171 self.wordApp.Windows(1).View.Type = wdNormalView 172 self.wordApp.Options.Pagination = False 173 self.wordApp.ScreenUpdating = False
174 175 # Save and Print
176 - def saveAs(self, filename):
177 self.wordDoc.SaveAs(filename)
178
179 - def Quit(self):
180 self.wordApp.Quit()
181
182 - def abandonWord(self):
183 #print "self.wordApp.DisplayAlerts",w.wordApp.DisplayAlerts 184 wdDoNotSaveChanges =0x0 # from enum WdSaveOptions 185 self.wordApp.Quit(wdDoNotSaveChanges)
186
187 - def printout(self):
188 self.wordDoc.PrintOut()
189
190 - def changeStartSelection(self, NChar=-1):
191 '''changes selection by NChar characters at Start''' 192 pbTextUnitCharacter = 1 193 self.wordSel.MoveStart( pbTextUnitCharacter, NChar )
194
195 - def changeEndSelection(self, NChar=-1):
196 '''changes selection by NChar characters at End''' 197 pbTextUnitCharacter = 1 198 self.wordSel.MoveEnd( pbTextUnitCharacter, NChar )
199 200 # Move the selection to the end, and insert into selection
201 - def selectEnd(self):
202 # ensures insertion point is at the end of the document 203 self.wordSel.Collapse(0)
204 # 0 is the constant wdCollapseEnd; don't want to depend 205 # on makepy support. 206
207 - def addText(self, text):
208 R = self.wordSel.InsertAfter(text) 209 self.selectEnd()
210 #return R 211
212 - def addSelectedText(self, text):
213 R = self.wordSel.InsertBefore(text)
214 #self.selectEnd() 215 #return R 216 217 ''' 218 Insert a paragraph in a named style 219 Fast, versatile, and lets graphic designers set the styles in Word. 220 >>> from win32com.client import constants 221 >>> mySelection.Style = constants.wdStyleHeading1 222 >>> 223 However, (a) this is limited to the built-in styles, and 224 (b) won't work without MakePy. 225 Our solution: get a style list back at run time, and use it to add them by name: 226 227 '''
228 - def getStyleList(self):
229 # returns a dictionary of the styles in a document 230 self.styles = [] 231 stylecount = self.wordDoc.Styles.Count 232 for i in range(1, stylecount + 1): 233 styleObject = self.wordDoc.Styles(i) 234 self.styles.append(styleObject.NameLocal)
235
236 - def addStyledPara(self, text, stylename):
237 if text[-1] <> '\n': 238 text = text + '\n' 239 self.wordSel.InsertAfter(text) 240 self.wordSel.Style = stylename
241
242 - def addTable(self, tableList, styleid=None, Range=None, fullWidth=0):
243 # Takes a 'list of lists' of data. 244 # first we format the text. You might want to preformat 245 # numbers with the right decimal places etc. first. 246 247 # replace last character in document if Range is empty 248 if Range==None: 249 Range = self.selectCharacter( -1 ) 250 251 textlines = [] 252 NRows = len( tableList ) 253 NCols = 1 254 for row in tableList: 255 if len(row)>NCols: 256 NCols = len(row) 257 258 #Tbl = self.wordDoc.Tables.Add(Range=Range, 259 # NumRows=NRows, NumColumns=NCols) 260 if fullWidth: 261 autofit = wdAutoFitWindow 262 else: 263 autofit = wdAutoFitContent 264 Tbl = self.wordDoc.Tables.Add( Range, NRows, NCols, wdWord9TableBehavior, autofit) 265 266 #Tbl.AutoFitBehavior = wdAutoFitContent 267 268 NR = 1 269 for row in tableList: 270 NC = 1 271 for s in row: 272 Tbl.Cell(NR, NC).Range.Text = str( s ) 273 NC += 1 274 NR += 1 275 276 #and format 277 if styleid: 278 Tbl.AutoFormat(Format=styleid) 279 280 Tbl.AllowPageBreaks = False 281 return Tbl
282
283 - def createTableStyle(self, name='myStyle', font='Arial', 284 color='', bgcolor='', 285 size=14, borders=1, bold=0, keepTogether=1):
286 287 styl = self.wordDoc.Styles.Add(Name=name, Type=wdStyleTypeTable) 288 styl.Font.Name = font 289 styl.Font.Size = size 290 291 if keepTogether: 292 styl.ParagraphFormat.KeepWithNext = True 293 styl.ParagraphFormat.KeepTogether = True 294 295 if bold: 296 styl.Font.Bold = True 297 else: 298 styl.Font.Bold = False 299 300 if len(bgcolor)>0: 301 try: 302 styl.Table.Shading.BackgroundPatternColor = colorDict[bgcolor] 303 except: 304 pass 305 306 if len(color)>0: 307 try: 308 #styl.Font.ColorIndex = textColorIndexDict[color] 309 styl.Font.Color = colorDict[color] 310 except: 311 pass 312 313 if borders: 314 styl.Table.Borders.Enable = True 315 else: 316 styl.Table.Borders.Enable = False 317 styl.Table.Borders.InsideLineStyle = wdLineStyleNone 318 styl.Table.Borders.OutsideLineStyle = wdLineStyleNone 319 styl.Table.Borders(wdBorderBottom).LineStyle = wdLineStyleNone 320 styl.Table.Borders(wdBorderLeft).LineStyle = wdLineStyleNone 321 styl.Table.Borders(wdBorderRight).LineStyle = wdLineStyleNone 322 styl.Table.Borders(wdBorderTop).LineStyle = wdLineStyleNone 323 styl.Table.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone 324 styl.Table.Borders(wdBorderVertical).LineStyle = wdLineStyleNone 325 326 return styl
327 328
329 - def addCellText(self, Table=None, row=1, col=1, text=''):
330 if Table==None: 331 return 332 333 Table.Cell(row, col).Range.Text = str( text )
334
335 - def setAllTableCellStyle(self, Table=None, StyleName=None):
336 if Table==None or StyleName==None: 337 return 338 339 for i in range(1, Table.Rows.Count+1): 340 for j in range(1, Table.Columns.Count+1): 341 try: 342 Table.Cell(i,j).Range.Style = StyleName 343 except: 344 pass
345
346 - def setCellStyle(self, Table=None, row=1, col=1, text='', 347 StyleName='', fontName='', fontSize=0, just='', bold=None, 348 color='', bgcolor='', width=0):
349 if Table==None: 350 return 351 352 if row<1: row=1 353 if row>Table.Rows.Count: row=Table.Rows.Count 354 if col<1: col=1 355 if col>Table.Columns.Count: col=Table.Columns.Count 356 357 if len(text)>0: 358 try: 359 Table.Cell(row, col).Range.Text = str( text ) 360 except: 361 pass 362 363 if len(StyleName)>0: 364 try: 365 Table.Cell(row,col).Range.Style = StyleName 366 except: 367 pass 368 369 if len(fontName)>0: 370 try: 371 Table.Cell(row,col).Range.Font.Name = fontName 372 except: 373 pass 374 375 if fontSize>0: 376 try: 377 Table.Cell(row,col).Range.Font.Size = fontSize 378 except: 379 pass 380 381 if len(just)>0: 382 try: 383 Table.Cell(row,col).Range.ParagraphFormat.Alignment = justDict[just] 384 except: 385 pass 386 387 if bold != None: 388 try: 389 Table.Cell(row,col).Range.Font.Bold = bold 390 except: 391 pass 392 393 if len(color)>0: 394 try: 395 Table.Cell(row,col).Range.Font.Color = colorDict[color] 396 except: 397 pass 398 399 if len(bgcolor)>0: 400 try: 401 Table.Cell(row,col).Range.Shading.BackgroundPatternColor = colorDict[bgcolor] 402 except: 403 pass 404 405 if width>0: 406 try: 407 Table.Cell(row,col).Width=width 408 except: 409 pass
410
411 - def mergeRow(self, Table=None, NRow=1):
412 if Table==None: 413 return 414 415 myrow = Table.Rows(NRow) 416 myrow.Cells.Merge()
417 418 '''Adding Charts and Images 419 Let's assume we've set up and saved an 420 Excel sheet with the right chart in it already. 421 '''
422 - def addInlineExcelChart(self, filename, caption='', 423 height=216, width=432):
424 # adds a chart inline within the text, caption below. 425 # add an InlineShape to the InlineShapes collection 426 #- could appear anywhere 427 shape = self.wordDoc.InlineShapes.AddOLEObject( 428 ClassType='Excel.Chart', 429 FileName=filename 430 ) 431 # set height and width in points 432 shape.Height = height 433 shape.Width = width 434 435 # put it where we want 436 shape.Range.Cut() 437 self.wordSel.InsertAfter('chart will replace this') 438 self.wordSel.Range.Paste() # goes in selection 439 self.addStyledPara(caption, 'Normal')
440
441 - def addImage(self, filename, Range=None, fracPage=0.5):
442 # without a range, the picture is added at the top 443 hw=self.wordDoc.InlineShapes 444 if Range==None: 445 Image = hw.AddPicture(filename) 446 else: 447 # AddPicture(FileName, LinkToFile, SaveWithDocument, Range) 448 print "Range provided for image add" 449 Image = hw.AddPicture(filename, False, True, Range) 450 451 PageW = self.wordDoc.PageSetup.PageWidth 452 desiredW = int( fracPage * PageW ) 453 if Image.Width > desiredW: 454 ratio = float( desiredW ) / Image.Width 455 Image.Width = int( ratio * Image.Width ) 456 Image.Height = int( ratio * Image.Height ) 457 458 return Image
459
460 - def selectParagraph(self, N=1):
461 # can also use negative numbers like python indexing 462 Ps = self.wordDoc.Paragraphs 463 if N<0: 464 N = Ps.Count + N + 1 465 if N<1: N=1 466 if N>Ps.Count: N = Ps.Count 467 468 RN = Ps(N).Range 469 RN.Select() 470 return RN
471
472 - def selectSentence(self, N=1):
473 # can also use negative numbers like python indexing 474 Ss = self.wordDoc.Sentences 475 if N<0: 476 N = Ss.Count + N + 1 477 if N<1: N=1 478 if N>Ss.Count: N = Ss.Count 479 480 RN = self.wordDoc.Range( Ss(N).Start, Ss(N).End) 481 RN.Select() 482 return RN
483
484 - def selectWord(self, N=1):
485 # can also use negative numbers like python indexing 486 Ws = self.wordDoc.Words 487 if N<0: 488 N = Ws.Count + N + 1 489 if N<1: N=1 490 if N>Ws.Count: N = Ws.Count 491 492 RN = self.wordDoc.Range( Ws(N).Start, Ws(N).End) 493 RN.Select() 494 return RN
495
496 - def selectCharacter(self, N=1):
497 Cs = self.wordDoc.Characters 498 if N<0: 499 N = Cs.Count + N + 1 500 if N<1: N=1 501 if N>Cs.Count: N = Cs.Count 502 503 RN = self.wordDoc.Range( Cs(N).Start, Cs(N).End) 504 RN.Select() 505 return RN
506 507 if __name__ == "__main__": #Self Test 508 509 w = WordWrap() 510 w.show() 511 512 # w.addText('Line 1\n\n') 513 # w.addText('Line 2\n\n') 514 # w.addText('Line 3\n\n') 515 # w.addText('Line 4\n\n') 516 517 from Summary import Summary 518 S = Summary( summaryTitle='Summary Title', subTitle='subtitle') 519 S.addAssumption( 'Assume this is a test' ) 520 521 S.addInput( label='Solar Flux', value=1.0, units='BTU/sqin', format='%g') 522 S.addOutput(label='Tea Temperature', value=100.0, units='C', format='%g') 523 524 summ = S 525 sel = w.selectCharacter(1) 526 527 w.changeEndSelection( -1 ) 528 529 #T1 = w.wordApp.Selection.ConvertToTable() 530 531 #w.wordDoc.Styles("Endnote Reference").Font.Size = 10 532 #w.wordDoc.Styles("Endnote Reference").Font.Name = "Courier New" 533 #w.setAllTableCellStyle( Table=T1, StyleName="Endnote Reference") 534 #T1.AutoFormat( Format=1 ) 535 536 #sel = w.selectCharacter(-1) 537 #x = raw_input("hit return to continue:") 538 539 #ps = u'Caption' 540 #w.addStyledPara( 'Now is not the time for any good men to come to the aid of their country.', ps) 541 542 #w.selectEnd() 543 544 tableStr = [('',),('',),('',),('','')] 545 wordTable1 = w.addTable( tableStr ) 546 w.mergeRow( Table=wordTable1, NRow=1) 547 w.mergeRow( Table=wordTable1, NRow=2) 548 549 w.addCellText(wordTable1, row=2, col=1, text='\n'.join(summ.getSummTopLines())) 550 w.addCellText(wordTable1, row=3, col=1, text='\n'.join(summ.getSummAssumptions())) 551 552 w.addCellText(wordTable1, row=4, col=1, text='\n'.join(summ.getSummInputs())) 553 w.addCellText(wordTable1, row=4, col=2, text='\n'.join(summ.getSummOutputs())) 554 555 # now format the table 556 w.wordDoc.Styles("Endnote Reference").Font.Size = 14 557 w.wordDoc.Styles("Endnote Reference").Font.Name = "Courier New" 558 w.setAllTableCellStyle( Table=wordTable1, StyleName="Endnote Reference") 559 wordTable1.AutoFormat( Format=1 ) 560 561 #w.addImage("C:\\Python25\\temp\\pyTest.png", Range=wordTable1.Cell(1,1).Range, fracPage=0.4) 562 #w.selectEnd() 563 #wordTable1.AutoFormat( Format=1 ) 564 '''Dim MyPic As Shape 'or InlineShape 565 566 Set MyPic = ActiveDocument.InlineShapes.AddPicture(strPathToPicture) 567 568 With MyPic 569 .RelativeVerticalPosition = wdRelativeVerticalPositionPage 570 .Left = CentimetersToPoints(0) 571 .Top = wdShapeBottom 572 End With''' 573 if 0: 574 w.getStyleList() 575 print w.styles 576 577 keyInp = raw_input(" Hit Key to Close Word") 578 w.abandonWord() 579