saywell Posted July 31, 2010 Share Posted July 31, 2010 I've got a script that automates letter filing - using standard template, standard file locations etc so documents can be found easiliy no matter who created them.Amongst other commands, it makes use of _WordDocSaveAs to save in proper location using proper file type; and _WordDocFindReplace to replace headings from the template with data read from an ini file.I've run it on a number of PCs [all XP] with Word 2002, 2003 and 2007.It works fine with all these versions of Word - except for 2 PCs when it throws errors due to inability to complete the save-as [on the first PC] or find & replace [on the second PC] actions. Both work fine if you save-as or F&R action from the Word menus.I suspect it's some subtle way the Word options etc are set on the 2 rogue machines, but I haven't been able to find any difference [they're on corporate machines, installed by ghosting the drives].Has anyone got any ideas as to the cause of the problems, and how I might fix it. Or even any pointers where to look in any Word/Office/Registry settings ?Many thanks,William Link to comment Share on other sites More sharing options...
seandisanti Posted July 31, 2010 Share Posted July 31, 2010 I've got a script that automates letter filing - using standard template, standard file locations etc so documents can be found easiliy no matter who created them. Amongst other commands, it makes use of _WordDocSaveAs to save in proper location using proper file type; and _WordDocFindReplace to replace headings from the template with data read from an ini file. I've run it on a number of PCs [all XP] with Word 2002, 2003 and 2007. It works fine with all these versions of Word - except for 2 PCs when it throws errors due to inability to complete the save-as [on the first PC] or find & replace [on the second PC] actions. Both work fine if you save-as or F&R action from the Word menus. I suspect it's some subtle way the Word options etc are set on the 2 rogue machines, but I haven't been able to find any difference [they're on corporate machines, installed by ghosting the drives]. Has anyone got any ideas as to the cause of the problems, and how I might fix it. Or even any pointers where to look in any Word/Office/Registry settings ? Many thanks, William what are the actual errors being returned, or the code that is causing them to be thrown? Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted July 31, 2010 Moderators Share Posted July 31, 2010 Add the following toward the top of your script, then provide the console output when running the code. _WordErrorHandlerRegister () Link to comment Share on other sites More sharing options...
saywell Posted August 1, 2010 Author Share Posted August 1, 2010 Add the following toward the top of your script, then provide the console output when running the code. _WordErrorHandlerRegister () Thanks, both. The machines are at work so I can't try anything until tomorrow at the earliest. The error code, from memory, was quite generic - to the effect that an error was passed back from Word as unable to complete the action, but I can be a bit more specific when I've done the above. Having looked at the help file for the error handler, I'll add something like the example script to my code as I can't install scite or autoit to the organisation's PCs to read the console. Thanks again, William Link to comment Share on other sites More sharing options...
saywell Posted August 2, 2010 Author Share Posted August 2, 2010 (edited) OK. I had a go at one of the PCs in the gaps between doing my day job!I think it is a problem with windoze on that PC.I installed the error-checking script as per the helpfile, with the addition of a write to an error-log. Checked it was working by provoking an attempt to save to a non-existent drive [and got appropriate error messages].On the PC that would save but then fail to do search/replaces, I got no error message - script just hangs.I then added 100mS delays between commands, and that bit worked fine. It now hangs later in the prog, when I'm trying to put the focus back on Word to write in some data from a string.I've tried winactivate(blah) and even followed it by winwaitactive (blah) but it refuses to take the focus!I'll try it again with a do sleep (1000) until winactive (blah) and see if it will work with a longer delay!My script is fine, as it works perfectly on all but one of the other PCs I've tried it on.The other PC fails to save, and I'll have a look at that tomorrow and report back.Whilst this doesn't seem to be an autoit or UDF problem, I'd appreciate any comments or suggestions from you guys with a broader experience [i'm a diagnostic radiologist by trade, not a programmer!]Regards,William Edited August 2, 2010 by saywell Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now