Python

Moderators: None (Apply to moderate this forum)
Number of threads: 473
Number of posts: 1172

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
opening a file inside a program Posted by Takar on 28 Jun 2006 at 6:28 AM
Does anybody know how to open a file with a program that you opened with Python, say Word?

thanks
Report
Re: opening a file inside a program Posted by infidel on 28 Jun 2006 at 8:50 AM
: 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?


infidel

$ select * from users where clue > 0
no rows returned


Report
Re: opening a file inside a program Posted by Takar on 28 Jun 2006 at 1:47 PM
: : 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?
:
:
: infidel
:
:
: $ select * from users where clue > 0
: no rows returned
: 

:
:

yes, that is what I was asking, sorry for the badly worded message.
Report
Re: opening a file inside a program Posted by Gregry2 on 28 Jun 2006 at 9:11 PM
: : : 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?
: :
: :
: : infidel
: :
: :
: : $ select * from users where clue > 0
: : no rows returned
: : 

: :
: :
:
: 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
Report
Re: opening a file inside a program Posted by infidel on 29 Jun 2006 at 8:52 AM
: : : 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?


infidel

$ select * from users where clue > 0
no rows returned


Report
Re: opening a file inside a program Posted by Takar on 29 Jun 2006 at 12:01 PM
: : : : 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?
:
:
: infidel
:
:
: $ select * from users where clue > 0
: no rows returned
: 

:
:
Yes, I opened Word with win32com
Report
Re: opening a file inside a program Posted by infidel on 30 Jun 2006 at 10:11 AM
This message was edited by Moderator at 2006-6-30 10:13:10

: 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:

w = Dispatch("Word.Application")
d = w.Open("C:\TEMP\Resume.doc")


The win32com stuff is pretty magical.

infidel

$ select * from users where clue > 0
no rows returned




Report
Re: opening a file inside a program Posted by Takar on 30 Jun 2006 at 2:51 PM
: This message was edited by Moderator at 2006-6-30 10:13:10

: : 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:
:
:
: w = Dispatch("Word.Application")
: d = w.Open("C:\TEMP\Resume.doc")
: 

:
: The win32com stuff is pretty magical.
:
: infidel
:
:
: $ select * from users where clue > 0
: no rows returned
: 

:
:
:
:
Thanks for all the help, I've got it figured out now



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.