Sign in to follow this  
Followers 0
jgus

Open MSWord .doc file

7 posts in this topic

This should be simple, but I'm not figuring it out. How do I open an MSWord .doc file? Not just MSWord itself, but a specific .doc file. It appears the run command will only open an executable file and I can't seem to figure out any parameters to have it open a specific file.

Share this post


Link to post
Share on other sites



This is an example:

Run(@ComSpec & ' /c Start "" "' & @MyDocumentsDir & '\document1.doc"', @SystemDir, @SW_HIDE)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Or via DllCall

$sCmd = 'c:\path\file.doc'
$sVerb = 'Open'
$sArg = '';Arguments
$sFolder = ''

$aRet = DllCall ("shell32.dll", "long", "ShellExecute", "hwnd", 0, "string", $sVerb, "string", $sCmd, "string", $sArg, "string", $sFolder, "long", @SW_SHOWNORMAL)
If $aRet[0] <= 32 Then
   MsgBox(16 + 4096,'Error','A problem occurred opening ' &  $sCmd)
EndIf
Edited by ezzetabi

Share this post


Link to post
Share on other sites

Or via DllCall

$sCmd = 'c:\path\file.doc'
$sVerb = 'Open'
$sArg = '';Arguments
$sFolder = ''

$aRet = DllCall ("shell32.dll", "long", "ShellExecute", "hwnd", 0, "string", $sVerb, "string", $sCmd, "string", $sArg, "string", $sFolder, "long", @SW_SHOWNORMAL)
If $aRet[0] <= 32 Then
   MsgBox(16 + 4096,'Error','A problem occurred opening ' &  $sCmd)
EndIf

<{POST_SNAPBACK}>

I like 'RunByAssoc' function, like an alternative to v3.0.102... :)

But, cool tip here with DLLCall. Thxs, ezze. :)

Share this post


Link to post
Share on other sites

This works perfect when I tried to open a .htm file i have on my hard drive but when I try to open a .txt or a .doc file I get this error

Line 166 (file"C Myprogramdir~)

If Run($szRegValue & $szFile) Then Return 1

Error: Unable to execute the external program.

The system cannot find the file specified.

Share this post


Link to post
Share on other sites

Ay screw it I just renamed the help file to .htm and it works.

At leat now the help file is non-editable :)

lol

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