Sign in to follow this  
Followers 0
Kaeft

Program Open File

6 posts in this topic

I haven't the fondest as to what I should search for so I'll post and see what I can get.

Is there a function that will take a program and open a file. Like if I wanted to open a document for microsoft office it would be something like ProgramOpenFile(title - "microsoft office", text "", File to open "stuffnjunk.doc"). Or is Controlsend an "alt f o" then ControlSetText "the filename/path" the only way to do that?

Thanks in advance.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Usually, those programs accept commandline parameters which can also be used for opening files.

Have you tried:

$officepath = 'C:\Program Files\Microsoft Office\Office12\" ;whatever the path to MS word is
$docfile = "test.doc" ;file you want opened
Run($officepath & "winword.exe " & $docfile)

EDIT: If you are looking for UDFs for Word or Excel, check the _Word* or _Excel* functions in the help file. As for other programs, not everything has a UDF of function, most specially the ones you normally do via commandline arguments.

Edited by omikron48

Share this post


Link to post
Share on other sites

Usually, those programs accept commandline parameters which can also be used for opening files.

Have you tried:

$officepath = 'C:\Program Files\Microsoft Office\Office12\" ;whatever the path to MS word is
$docfile = "test.doc" ;file you want opened
Run($officepath & "winword.exe " & $docfile)

Ok yeah that would be pretty simple. If all else fails I will definitely use that. Thanks!

Would that work if the program was already running?

Share this post


Link to post
Share on other sites

I think it opens a new instance every time.

Share this post


Link to post
Share on other sites

I use the ShellExecute function


I ran. I ran until my muscles burned and my veins pumped battery acid. Then I ran some more.

Share this post


Link to post
Share on other sites

That's if the program you want is associated to that particular file type. I'm tackling the case where you want an arbitrary program opening a particular file.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0