WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: morenos1 on January 06, 2017, 06:57:01 AM

Title: Word print.
Post by: morenos1 on January 06, 2017, 06:57:01 AM
This code fails to find the document in Windows 10 when I can see it there? .. (Windows 7 works..)

;   create word object...
oWord = objectopen("Word.Application")
;   set the documents object...
oDocs = oWord.documents
;   open a preset file...
oDocs.open("C:\temp\test.doc")
;get active document
oDoc = oWord.ActiveDocument
;   make word visible...
oWord.visible = @True ;Change to @False to hide
oWord.PrintOut(::FileName="C:\temp\test.doc")

oDoc.Save
oDoc.Close
oWord.Quit
ObjectClose(oDoc)
ObjectClose(oDocs)
ObjectClose(oWord)
Title: Re: Word print.
Post by: td on January 06, 2017, 07:31:40 AM
You didn't mention which line generated the error and your exact script works just fine on one of our Windows 10 systems so it is hard to say why you are getting the error.  The Windows 10 usual suspect  is UAC but it is not clear how UAC would cause this error in this case.
Title: Re: Word print.
Post by: morenos1 on January 06, 2017, 07:49:45 AM
Line 7. UAC disabled ....
Title: Re: Word print.
Post by: morenos1 on January 06, 2017, 07:52:14 AM
Error..
Title: Re: Word print.
Post by: morenos1 on January 06, 2017, 08:02:01 AM
Sorry this is the correct error line:
Title: Re: Word print.
Post by: td on January 06, 2017, 08:12:58 AM
Quote from: morenos1 on January 06, 2017, 07:49:45 AM
Line 7. UAC disabled ....

'UAC dispabled' can mean different things to different people.  It can mean that UAC prompting is turned off which is not that same thing as UAC being turned off.  Or it can mean that either directly via the registry or group policy UAC is completely disabled.  If the later is the case, administrators are not able to run 'Modern' apps nor modify certain system settings via the systems 'Settings' applet.  But again this may be a red-herring.
Title: Re: Word print.
Post by: morenos1 on January 06, 2017, 08:17:04 AM
Set to "Never notify". However, I can see the document in explorer and, open it with word ...
Title: Re: Word print.
Post by: td on January 06, 2017, 08:55:05 AM
Assuming  you are using an admin account then that means that you are opening the document as a restricted admin from Explorer and as a full admin from WinBatch.    It is unclear how that would cause your problem unless the directory or file had some very unusual permissions or the 'temp' directory is some kind of reparse point.

You could experiment with opening the file readonly but not sure that this would help any.

https://msdn.microsoft.com/en-us/library/office/ff835182.aspx (https://msdn.microsoft.com/en-us/library/office/ff835182.aspx)
Title: Re: Word print.
Post by: td on January 06, 2017, 09:23:07 AM
You could also try renaming your script's file extension from '.wbt' to '.wbt_if'.  This could confirm or eliminate UAC as the problem.
Title: Re: Word print.
Post by: morenos1 on January 06, 2017, 10:23:07 AM
For some reason the word files are saved as:  filename.doc.docx ??

As soon as I deleted .docx the file was found ......

Thank You ....
Title: Re: Word print.
Post by: td on January 06, 2017, 11:16:30 AM
If you uncheck the Explorer Folder Option "Hide extensions for known file types" option, file extensions will always be visible from an Explorer window.