COM file references

Colin Meeks colinmeeks at rogers.com
Wed Feb 20 10:43:43 CET 2002


Hi Matt

Please pardon me if I do a spelling mistake, but it's gone 4:30am and I need
to sleep :-)
You only need to pass the base file name, I.e. the bit without the
extension. You would
also make the program a bit more intelligent and check for trailing slashes
in the
paths and double them up where necessary.  This should get you on the right
track though

regards

Colin

P.S.  Sorry if Outlook strews up the formatting.

def ConvertToText(UseFileName, UseInPath, UseOutPath):
    try:
        import win32com.client
        w=win32com.client.Dispatch("Word.Application")
        w.Visible=1
        w.Documents.Open(UseInPath+UseFileName+".doc")
        #save file as text file - number '5' is position of word to text
converter
        #in the word 'file type' dialogue
        w.ActiveDocument.SaveAs (UseOutPath+UseFileName+".txt", 5)
        w.ActiveDocument.Close(SaveChanges=0)
        return(1)
    except:
        return(0)



>
> However, I really need to turn this into a function to which I can pass an
> input file name and path, and an output file name and path.
>
> This is troubling me - however I try, I can't work out how to pass the
path
> and file to the 'Documents.Open' expression (or vice-versa)
>
> If anyone could offer any guidance I would really appreciate it. -
Apologies
> for the astonishingly simple nature of the query!
>
> cheers
>
> Matt
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.324 / Virus Database: 181 - Release Date: 14/02/2002





More information about the Python-list mailing list