From thierry.marneffe at skynet.be Wed Jan 4 21:06:03 2012 From: thierry.marneffe at skynet.be (Thierry Marneffe) Date: Wed, 4 Jan 2012 22:06:03 +0100 Subject: [windev] CDispatch and COleDispatch on MS Word Automation In-Reply-To: <19BF22AFB2E07C468DA209A14E441EBC2BEF14A2@BLR-EC-MBX6.wipro.com> References: <0FB5495A7A2D42E19760CF18135B9929@TGMPC02> <19BF22AFB2E07C468DA209A14E441EBC2BEF14A2@BLR-EC-MBX6.wipro.com> Message-ID: <232D851959F44276BE676BCB448B642A@TGMPC02> Hello Well ... I change the Visible Mode and .... it works // Automate Word but in Normal Mode WordApp.put_Visible( TRUE); Don't know why !!!!! Thierry EMail: thierry.marneffe at skynet.be Web: www.tgmdev.be Download Isanaki 2.6b, the latest version of Isanaki Sudoku, a free multilingual Sudoku and Wordoku Generator, Solver and Helper ... at www.tgmdev.be Download KillProcess 3.0, the latest version of KillProcess, a free utilities to kill any Windows XP process or services ... at www.tgmdev.be Download Genesis 1.2, a free OPC Client Data Acquisition and Reporting at www.tgmdev.be Download Horses 2.0, the latest version of Horses, a free version of the classical Horses Puzzle... at www.tgmdev.be -----Original Message----- From: rajasekhar.amirapu at wipro.com Sent: Tuesday, December 27, 2011 7:28 AM To: thierry.marneffe at skynet.be ; windev at windev.org Subject: RE: [windev] CDispatch and COleDispatch on MS Word Automation Hi Thierry, Please give permissions in DCOM Config and try it should work, Thanks & Regards, RAJA Sekhar -----Original Message----- From: windev-bounces at windev.org [mailto:windev-bounces at windev.org] On Behalf Of Thierry Marneffe Sent: Friday, December 23, 2011 10:51 PM To: windev at windev.org Subject: [windev] CDispatch and COleDispatch on MS Word Automation Hello I'm using Word Automation to create automatically some Word files. The program was written for MSWord 2007 and everything works file. We switch to Office 2010 and troubles arose. According to the PC the software is running on, calling the Open function to open an existing .doc (or .docx) files gives three different reactions: * everything fine * a CDispatch exception error * a COleDispatch exception error : SCODE: 0000000 Command Failed Here is the code (with class generated from .olb file from Office 2010) CWordApplication WordApp; CWordDocuments WordDocs; CWordDocument WordDoc; try { // Create Instance of Word if ( !WordApp.CreateDispatch( "Word.Application")) { AfxMessageBox( "Fail to Start Word Automation !!!!!"); return false; } // Automate Word but in Hidden Mode WordApp.put_Visible( FALSE); WordDocs = WordApp.get_Documents(); WordDoc = WordDocs.Open( COleVariant( strPath, VT_BSTR), vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional); This is where the function generate a COleDispatchException ..... Any information of things that could have changed in Word 2010 ? Thanks for your help ... Happy Christmas everybody !!! Thierry EMail: thierry.marneffe at skynet.be Web: www.tgmdev.be Download Isanaki 2.6b, the latest version of Isanaki Sudoku, a free multilingual Sudoku and Wordoku Generator, Solver and Helper ... at www.tgmdev.be Download KillProcess 3.0, the latest version of KillProcess, a free utilities to kill any Windows XP process or services ... at www.tgmdev.be Download Genesis 1.2, a free OPC Client Data Acquisition and Reporting at www.tgmdev.be Download Horses 2.0, the latest version of Horses, a free version of the classical Horses Puzzle... at www.tgmdev.be -- Windev mailing list at Windev at windev.org Lost your password? Need to unsubscribe or change your delivery options? Go to http://lists.windev.org/mailman/listinfo/windev -- Search the Windev Archives - www.windev.org Please do not print this email unless it is absolutely necessary. The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com