donnyh13

problems opening Word?

11 posts in this topic

Hi all, I had created a script back in november with the latest at that time of autoit, it worked and then I didnt need it since. now I have downloaded the latest auto it on a different computer and copied the same script over. it works except for when it get to the spot where its supposed to open a word doc. this wont work. I have tried making a new script solely meant to open a word doc, and cannot get it to open, what am I doing wrong?

 

this is my code,

#include <Word.au3>


Local $location = InputBox( "Location.", "What is the name of the file including the extension, {for example .rtf}")
Sleep ( 3000)
Local $WordCreate = _Word_Create()
Sleep ( 3000)
Local $path = @ScriptDir & "\"&$location
Sleep ( 3000)
_Word_DocOpen( $WordCreate, $path,)

I would normally run the script it would prompt for where its located, which I would enter the name including the extension, for example "open.rtf". which is located in the same place im running my script from. Is there something im missing?? something that changed with a recent update?

thanks

Share this post


Link to post
Share on other sites



Your code has a few typos. Try this:

#include <Word.au3>

Local $location = InputBox( "Location.", "What is the name of the file including the extension, {for example .rtf}")
Local $WordCreate = _Word_Create()
Local $path = @ScriptDir & "\" & $location
_Word_DocOpen( $WordCreate, $path)

And I don't believe the sleeps are needed either.

 

-DakotaSamuel

Share this post


Link to post
Share on other sites

When you run your script from SciTE do you get any error messages?


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

Thanks for the replies, 

Your code has a few typos. Try this:

#include <Word.au3>

Local $location = InputBox( "Location.", "What is the name of the file including the extension, {for example .rtf}")
Local $WordCreate = _Word_Create()
Local $path = @ScriptDir & "\" & $location
_Word_DocOpen( $WordCreate, $path)

And I don't believe the sleeps are needed either.

 

-DakotaSamuel

I did try the code, still nothing, I run it and it just runs and goes away, the word I specify doesnt open.no erroes etc. im wondering if it is something to do with my computer?  

Share this post


Link to post
Share on other sites

What versions of Autoit and Word do you have installed?

 

-DakotaSamuel

Share this post


Link to post
Share on other sites

Thanks for the replies, 

I did try the code, still nothing, I run it and it just runs and goes away, the word I specify doesnt open.no erroes etc. im wondering if it is something to do with my computer?  

You have no error checking, so It wouldn't report an error.

Does this display an error?

 

#include <Word.au3>

Local $location = InputBox( "Location.", "What is the name of the file including the extension, {for example .rtf}")
Local $WordCreate = _Word_Create()
Local $path = @ScriptDir & "\" & $location
_Word_DocOpen( $WordCreate, $path)
If @Error Then Msgbox(0,'',"_Word_DocOpen returned @error: " & @error)

 

Share this post


Link to post
Share on other sites

Hi Kaisies, woops, I thought you meant the syntax check type errors. I tried your code and it returned code 1

 

The installer says 3.3.12.0 for autoit. 

I am actually using WPS writer ( which worked before with the old code) that version is 9.1.0.4758

Thanks

Share this post


Link to post
Share on other sites

You should look at the doc open udf page and look at what error 1 means :) 

1 person likes this

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Thanks Kaisies,

any hints on how to correct it? as I am not very fluent in all of this code language :P

Edited by donnyh13

Share this post


Link to post
Share on other sites

@error = 1 means: $oAppl is not an object
It looks like _Word_Create already returned an error. I suspect there is no MS Word installed on your machine.

1 person likes this

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

Thanks,

I really appreciate your help!

 

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