srwhale Posted August 20, 2015 Share Posted August 20, 2015 Hello all,I've got a script that opens up an existing word template (docx), does some replacements and pastes in a load of stuff from certain text files, then does a save as with a particular file name. Except I'm running into the problem that the SaveAs opens a dialogue box even though the file path specified seems to be valid.Is there a way of making it so the dialogue box doesn't show up? This script loops hundreds of times so I would to not have to enter the file name each time! The folder I am using already exists, but the file does not.I've been scratching my head over this for a few days now. Below is a cut down version of my script - is there anything that I am doing wrong?I'm working on Windows 7 and Word 2013, if that's relevant.Thanks,~srwhale #include <Array.au3> #include <File.au3> #include <Word.au3> $sNewFileLocation = "D:\OCR\AutoDocx" ;This folder already exists Global $aFileNames = ["Foo1","Foo2","Bar1","Bar2"] Global $sTemplate = "D:\OCR\IS_template_2.docx" For $i = 1 to UBound($aFileNames)-1 Local $oWord = _Word_Create() $oDoc = _Word_DocOpen($oWord,$sTemplate,Default,Default,False) ;'False' = Not read only ;Makes replacements, pastes stuff in etc. $sNewDocxLocation = $sNewFileLocation&"\IS"&$aFileNames[$i]&".docx" MsgBox(0,"Info","Saving to "&$sNewDocxLocation) _Word_DocSaveAs($oDoc,"'"&$sNewDocxLocation&"'",$WdFormatDocumentDefault) ;I've tried several things - double quotes in case there is a space, trying different formats or omitting that bit, etc. _Word_DocClose($oDoc) Next Link to comment Share on other sites More sharing options...
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
Already have an account? Sign in here.Sign In Now