#1
  1. PHP Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Location
    England
    Posts
    163
    Rep Power
    13

    Python, Com and Ms Word


    Firstly, i apologise as i didn't know where else to put this, i'm using python and COM to interact with MS Word, i'm trying to find the API that i can use to invoke the search and replace within word, so it replace every instance of ANDY with BOB.


    Code:
    		pythoncom.CoInitializeEx(pythoncom.COINIT_APARTMENTTHREADED)
    		Word = win32com.client.DispatchEx('Word.Application')
    		Word.visible = 0
    		Word.Application.ActivePrinter = printer
    		doc = Word.Documents.Open(wordfile, False, False, False)
                    # do replacing here
    		#print
    		while Word.BackgroundPrintingStatus > 0:
    			time.sleep(0.1)
    		doc.Close()
    		Word.Quit()
    		del doc
    		del Word

    Then its gonna print the doc and quit without saving.



    Also, does anyone know where on MSDN where the documentation is for what API's word exposes thru COM.

    Thanks

    andy
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Location
    Regensburg, Germany
    Posts
    147
    Rep Power
    16

IMN logo majestic logo threadwatch logo seochat tools logo