opening a file inside a program - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

opening a file inside a program

TakarTakar Posts: 4Member
Does anybody know how to open a file with a program that you opened with Python, say Word?

thanks

Comments

  • infidelinfidel Posts: 2,900Member
    : Does anybody know how to open a file with a program that you opened with Python, say Word?

    I don't understand the question. Are you saying you used Python to start MSWord, and you want the Python code to make MSWord open a particular file?


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

    [code]
    $ select * from users where clue > 0
    no rows returned
    [/code]

  • TakarTakar Posts: 4Member
    : : Does anybody know how to open a file with a program that you opened with Python, say Word?
    :
    : I don't understand the question. Are you saying you used Python to start MSWord, and you want the Python code to make MSWord open a particular file?
    :
    :
    : [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]
    :
    : [code]
    : $ select * from users where clue > 0
    : no rows returned
    : [/code]
    :
    :

    yes, that is what I was asking, sorry for the badly worded message.
  • Gregry2Gregry2 Posts: 607Member
    : : : Does anybody know how to open a file with a program that you opened with Python, say Word?
    : :
    : : I don't understand the question. Are you saying you used Python to start MSWord, and you want the Python code to make MSWord open a particular file?
    : :
    : :
    : : [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]
    : :
    : : [code]
    : : $ select * from users where clue > 0
    : : no rows returned
    : : [/code]
    : :
    : :
    :
    : yes, that is what I was asking, sorry for the badly worded message.
    :

    Most programs, if you call it from the cmdline, its first argument is a file to open. I forgot Python's equivalent of the system() call in C, but you can use that to call msword then concat the filename you want to open.

    Search the docs for the sys package, the function u need should be there.
    {2}rIng
  • infidelinfidel Posts: 2,900Member
    : : : Does anybody know how to open a file with a program that you opened with Python, say Word?
    : :
    : : I don't understand the question. Are you saying you used Python to start MSWord, and you want the Python code to make MSWord open a particular file?
    :
    : yes, that is what I was asking, sorry for the badly worded message.

    Ok, how did you open MSWord? Using the automation library ("Word.Application" or something like that) via the win32com python module?


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

    [code]
    $ select * from users where clue > 0
    no rows returned
    [/code]

  • TakarTakar Posts: 4Member
    : : : : Does anybody know how to open a file with a program that you opened with Python, say Word?
    : : :
    : : : I don't understand the question. Are you saying you used Python to start MSWord, and you want the Python code to make MSWord open a particular file?
    : :
    : : yes, that is what I was asking, sorry for the badly worded message.
    :
    : Ok, how did you open MSWord? Using the automation library ("Word.Application" or something like that) via the win32com python module?
    :
    :
    : [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]
    :
    : [code]
    : $ select * from users where clue > 0
    : no rows returned
    : [/code]
    :
    :
    Yes, I opened Word with win32com
  • infidelinfidel Posts: 2,900Member
    [b][red]This message was edited by Moderator at 2006-6-30 10:13:10[/red][/b][hr]
    : Yes, I opened Word with win32com

    Ok, then you'll need to look up the Word API somewhere, probably on MSDN I would guess. There's probably a .Open method on the application object or something like that.

    You can just call the Word methods on your python object, something like:

    [code]
    w = Dispatch("Word.Application")
    d = w.Open("C:TEMPResume.doc")
    [/code]

    The win32com stuff is pretty magical.

    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

    [code]
    $ select * from users where clue > 0
    no rows returned
    [/code]



  • TakarTakar Posts: 4Member
    : [b][red]This message was edited by Moderator at 2006-6-30 10:13:10[/red][/b][hr]
    : : Yes, I opened Word with win32com
    :
    : Ok, then you'll need to look up the Word API somewhere, probably on MSDN I would guess. There's probably a .Open method on the application object or something like that.
    :
    : You can just call the Word methods on your python object, something like:
    :
    : [code]
    : w = Dispatch("Word.Application")
    : d = w.Open("C:TEMPResume.doc")
    : [/code]
    :
    : The win32com stuff is pretty magical.
    :
    : [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]
    :
    : [code]
    : $ select * from users where clue > 0
    : no rows returned
    : [/code]
    :
    :
    :
    :
    Thanks for all the help, I've got it figured out now
Sign In or Register to comment.