Jump to content

Open Word Document


gmcfad
 Share

Recommended Posts

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

Link to comment
Share on other sites

  • Moderators

@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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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...