473,508 Members | 2,130 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Where is Word?

Hi all,

I need a way to get the path where MS Word/Office has been installed. I need
to start Word from a script (see earlier post), but it doesn't work if I
don't know its path. So "os.system("winword.exe %s" % fileName)" doesn't
always work; I need to say "os.system("C:\Program Files\Microsoft
Office\Office10\winword.exe %s" % fileName)".

Any ideas?

TIA,
g
Jul 19 '05 #1
6 1429
Guy Lateur wrote:
I need a way to get the path where MS Word/Office has been installed. I need
to start Word from a script (see earlier post),


(Asking us to refer to some earlier post that may or may not even be
available on our news servers isn't the best way to get us the info. A
sentence or two summarizing would work best, I think.)

Can you describe what the user is going to do after Word pops open with
this file in it? Maybe there are simpler ways to do what you are trying
to accomplish, aside from the specific issue of how to open Word itself.

For example, maybe the work you plan to have the user accomplish can be
done automatically by controlling Word with COM.

-Peter
Jul 19 '05 #2
My original post is called "Start application & continue after app exits".
Is there a better way to refer to past posts, btw?

I want to make a temporary file (directory listing), open it in Word to let
the user edit, layout and print it, and then delete the temp file
afterwards. I don't think we'll be able to fully automate it, though. The
user should be able to set her own fonts and stuff.

g

"Peter Hansen" <pe***@engcorp.com> schreef in bericht
news:zN********************@powergate.ca...
Guy Lateur wrote:
I need a way to get the path where MS Word/Office has been installed. I
need to start Word from a script (see earlier post),


(Asking us to refer to some earlier post that may or may not even be
available on our news servers isn't the best way to get us the info. A
sentence or two summarizing would work best, I think.)

Can you describe what the user is going to do after Word pops open with
this file in it? Maybe there are simpler ways to do what you are trying
to accomplish, aside from the specific issue of how to open Word itself.

For example, maybe the work you plan to have the user accomplish can be
done automatically by controlling Word with COM.

-Peter

Jul 19 '05 #3
Guy Lateur wrote:
My original post is called "Start application & continue after app exits".
Is there a better way to refer to past posts, btw?
No, the subject is a good way to refer to past posts. I just meant
forcing us to dig back, when the post may no longer even be on our
servers, is not helpful.
I want to make a temporary file (directory listing), open it in Word to let
the user edit, layout and print it, and then delete the temp file
afterwards. I don't think we'll be able to fully automate it, though. The
user should be able to set her own fonts and stuff.


I understand now. Definitely if you are doing this to allow customizing
fonts and such, at the user's whim, you can't automate it, by definition...

(Perhaps I should ask why anyone would want to waste time putting
arbitrary fonts and colours and such around a simple directory listing,
but I won't. <wink>)

-Peter
Jul 19 '05 #4
No, the subject is a good way to refer to past posts. I just meant
forcing us to dig back, when the post may no longer even be on our
servers, is not helpful.
I agree, my bad.

(Perhaps I should ask why anyone would want to waste time putting
arbitrary fonts and colours and such around a simple directory listing,
but I won't. <wink>)


Please don't.. ;)

g
Jul 19 '05 #5
Thanks for all the feedback, everyone. What a helpfull community this is!
It's actually kinda hard keeping up with y'all..

Cheers,
g
"Guy Lateur" <gu********@b-b.be> schreef in bericht
news:uF**********************@phobos.telenet-ops.be...
Hi all,

I need a way to get the path where MS Word/Office has been installed. I
need to start Word from a script (see earlier post), but it doesn't work
if I don't know its path. So "os.system("winword.exe %s" % fileName)"
doesn't always work; I need to say "os.system("C:\Program Files\Microsoft
Office\Office10\winword.exe %s" % fileName)".

Any ideas?

TIA,
g

Jul 19 '05 #6
Ok, I've tried various proposed solutions, and this is what I've come up
with:

<code>
# get Word path
wordKey = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE,
'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths', 0, win32con.KEY_READ)
wPath = win32api.RegQueryValue(wordKey, 'winword.exe')
win32api.RegCloseKey(wordKey)

# open/write tempfile & delete afterwards
fD, fN = tempfile.mkstemp('.txt')
fH = os.fdopen(fD, 'w')
fH.write('blabla')
fH.close()
os.spawnl(os.P_WAIT, wPath, 'winword.exe', fN)
os.remove(fN)
</code>
The above seems to work ok, but if you run the script a second time without
first closing Word(1), the os.spawnl() doesn't seem to block. As a
consequence, the tempfile is not removed (because Word still has it open
when os.remove(fN) is called).

Is this behaviour normal? Anything I can do about this?

Thanks,
g
Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1490
by: Bengt Richter | last post by:
We have where syntax in combination with suite expression syntax (bear with me, I think a good synergy will emerge ;-) ...
0
1037
by: Guy Lateur | last post by:
Hi all, This goes back to my previous post called "Where is Word". In short, I wanted to make a temporary file (directory listing), open it in Word to let the user edit, layout and print it, and...
1
2434
by: dkultasev | last post by:
I mean, I am trying to use Microsoft word with Borland C++ Builder. I found some examples like that: Variant V; V = CreateOleObject("Word.Basic"); V.Exec(Procedure("AppShow"));...
42
2112
by: x-pander | last post by:
Is is guaranteed, that a pointer to any object in C points exactly at the lowest addressed byte of this object? Specifcally is it possible for any platform/os/compiler combination that: (char...
2
2290
by: Lampa Dario | last post by:
Hi, where is this stupid error in this program? When I execute it, i receive a segmentation fault error. #include <stdio.h> int main(int argc, char *argv, char *env) { int i=0; int l=0; int...
57
3747
by: TC | last post by:
I'd like to open a discussion about the state of the industry. For the past year, I've been unable to find competent Access developers available for hire. I'm worried about that. I think there's...
1
2492
by: mimenko | last post by:
Hello, I like to play with letters, and I try to find some websites on which I could find source codes of word games, like crossword, scrabble, anagrams, word utilities,... , and other games but...
0
7326
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7383
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3194
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.