Jump to content
gmcfad

Open Word Document

Recommended Posts

gmcfad

Trying to open MSWord with a specific document. I've tried both of the solutions below and all I get are  the errors:

 $sWordFile = "C:\Users\gm185170\Desktop\Daily.doc"
FileChangeDir ("C:\Users\gm185170\Desktop")
Run("C:\Program Files (x86)\Microsoft Office\root\Office16\Winword.exe " &  $sWordFile)

ERROR: Sorry, we couldn't find your file. Was it moved, renamed, or deleted? (C:\Users\gm185170\Desktop\Daily.doc)

 

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

ERROR: 

'Windows cannot find 'C:\users\gm185170\Documents\Daily.doc'. Make sure you typed the name correctly, and then try again.

 

I have multiple copies of the doc file on both my desktop and in my documents dir....

thanks

Share this post


Link to post
Share on other sites
JLogan3o13

@gmcfad welcome to the forum. Try something like this:

ShellExecute(@MyDocumentsDir & "\Daily.doc")

It works well when I place a file named Daily in that directory. If that does not work for you, it is something specific to your system. You'll need to confirm Word is set to open .doc files by default.

As an aside, once you get past this hurdle, if you are looking to manipulate the Word document after opening, have a look at the _Word* functions in the help file.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
gmcfad

Tried you recommendation - received the same error:  'Windows cannot find 'C:\users\gm185170\Documents\Daily.doc'. Make sure you typed the name correctly, and then try again.

Verified that Word is default prog for .doc file types. 

Share this post


Link to post
Share on other sites
water

Did you verify that the file really exists in this Directory? Is it a .doc or a .docx file?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
gmcfad

Major DUH! moment....HA! HA! The file name is Daily.doc.docx.........my bad.  )-:

And the shellexecute works fine.

Thanks!!

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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.