Microsoft Word Error 0 Command Failed
SQL Server 2014 Express resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Samples Retired content We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: Documents.Open(...) throws "Command failed" error in Word 2010 when User Templates are stored on a network share Microsoft Office for Developers > Word for Developers Question 0 Sign in to vote Hi, I have a C# (.Net 2.0) desktop application that uses COM interop to automate Word. The application was created a few years agousing the Office XP automation interface and works with Word 2002, 2003 and Word 2007, but not with Word 2010 under certain conditions. Our clients keep their Office User Templates on a network share and configure Word to use that location( Options | Advanced | File locations). I've reproduced the problem in a simple test app. To reproduce in Word 2010, configure your WordUser Templates to point to a network location. In the Trust Center set Word to trust network locations and add your new location(initially I thought that this would be the fix). The following code breaks, but if a sufficientdelay is introduced it works. I didn't experiencethe problem using a local User template location. The error raised on the Documents.Open call is System.Runtime.InteropServices.COMException (0x800A1066): Command failed Is this a Word bug/setting, an interop setting/problem, oris there a way for me to receive an event of some sort when the Application object is in an intializedand working state? - Adding sleep statements in my code is not a good solution - somewhere out in my client base will be a machine where that sleep value wont work. Thanks for your time Bruce object filename = @"C:\temp\worddoc.tmp"; object missing = System.Reflection.Missing.Value; _Application app = new Microsoft.Office.Interop.Word.Application(); app.Visible = true; // Thread.Sleep(1000); app.Documents.Open(ref filename, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); //app.Quit(ref missing, ref missing, ref missing); Wednesday, March 09, 2011 6:39 AM Reply | Quote Answers 0 Sign in to vote Hello Bruce, You ask w
Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Software Quality Assurance & Testing beta Questions Tags Users Badges Unanswered Ask Question _ Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute: Sign up Here's how it works: Anybody can https://social.msdn.microsoft.com/Forums/en-US/e85fdc15-3a79-40ff-85a3-d85956e65a19/documentsopen-throws-command-failed-error-in-word-2010-when-user-templates-are-stored-on-a?forum=worddev ask a question Anybody can answer The best answers are voted up and rise to the top What could cause a “command failed” error when using the Word.Application object to compare two documents? up vote 6 down vote favorite 1 I have two word documents that are a "result" of a test and an "expected result". I'm using the following code to compare the two and check for differences. Sub CompareTest Dim http://sqa.stackexchange.com/questions/1015/what-could-cause-a-command-failed-error-when-using-the-word-application-object wrdApp Dim revTemp Dim file1, file2, differences Set wrdApp = Sys.OleObject("Word.Application") file1 = "C:\TestDocs\Site Initiation.doc" file2 = "C:\TestDocs\Site Initiation_observer.doc" differences = "C:\TestDocs\differences.doc" call wrdApp.Documents.Open(file1) call wrdApp.ActiveDocument.Compare(file2, "", 1) Set revTemp = wrdApp.Selection.NextRevision(True) If Not (revTemp Is Nothing) Then wrdApp.ActiveDocument.SaveAs differences wrdApp.Documents.Close Call Log.Warning "Documents are not identical", "Please see the differences in " & differences Else Call Log.Message "Documents are identical" End If wrdApp.Quit False End Sub For whatever reason, for most of the word documents we're comparing like this, everything works fine. However, for two of them we're comparing, we're getting "Command Failed" on the line that is calling the "Compare" method. I've searched Microsoft's library on line, numerous blogs, etc., and no one can give me a specific situation where this code would work for MOST documents but not for certain scenarios. I've tried reversing the order of the documents, changing the document names and the directory paths to be more compatible with an 8.3 format. I've tried comparing each document to itself as well. A little help would be greatly appreciated. FYI, this is code being run in the TestComplete automated testing tool so the specifics of "Sys.OleObject" and the "Log" object are internal to that tool. We've used "CreateObject" and commented out the Log calls to no avail. automat
for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a Question Ask for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Expand Search https://www.experts-exchange.com/questions/27812669/Command-Failed-Error-Opening-a-Word-Document-from-Access.html Submit Close Search Login Join Today Products BackProducts Gigs Live Careers Vendor Services Groups Website Testing Store Headlines Experts Exchange > Questions > Command Failed Error Opening a Word Document from Access Want to Advertise Here? Solved Command Failed Error Opening a Word Document from Access Posted on 2012-08-01 MS Applications MS Office MS Access 1 Verified Solution 9 Comments 1,327 Views Last Modified: 2012-08-08 We have an Access Database that is running at a microsoft word number of sites (each independent) and they generate letters to Word using the following code. (The first line outputs a record to Excel as the security in Access seems to make it difficult to merge to a query. It appears to be the second line that is causing the problem) 'Output data to datasource for merge DoCmd.OutputTo acQuery, "Letters_Family", "MicrosoftExcelBiff5(*.xls)", "V:\DataSources\SourceFamily.xls", False, "", 0 ' Open the microsoft word error letter template in Word to merge Dim WordApp, WordDoc As Object Set WordApp = CreateObject("Word.Application") Set WordDoc = WordApp.Documents.Open("V:\Templates_ReferralLetters\FamilyConsentRequest.dot") WordApp.Visible = True WordDoc.Activate This works absolutely fine at 10 of the 11 sites however at one they get a Command Failed error the first time they click the command button. If they click it again it goes through fine. When they move to a new person's record the problem starts again. They are using Office 2010. Does anyone have any idea why this would be happening. Thanks in advance 0 Question by:PerksP Facebook Twitter LinkedIn Google Best Solution byPerksP Thanks so much for trying to help but whatever i did the command failed came up. I rummaged around the internet a bit and found that there is a hotfix which fixes the inconsistent operation of Word templates. Go to Solution 9 Comments LVL 26 Overall: Level 26 MS Access 12 MS Office 11 MS Applications 6 Message Active today Expert Comment by:MacroShadow2012-08-01 It would seem that Word is not finished initializing and so WordApp.Documents.Open fails, it is more common in environments where Normal.dotm is stored on a network-drive. A work around is Loop Sleep 300 and try again, hopefully this will allow Word enough time to initialize. 0 Message Author Comment by:PerksP2012-08-01