Jump to content

Open MSWord .doc file


jgus
 Share

Recommended Posts

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.

Link to comment
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
Edited by ezzetabi
Link to comment
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. :)

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...