none
Odd Error on SaveAs - Please help RRS feed

  • Question

  • Hi

    Not sure i've posted on the right fórum but here goes

    I have an application written in C# that uses Word Interop to handle some Word Docs. Part of the process entails comparing two docs for added/deleted words, so i open both documents, do a compare on them (from which i get a third document with track changes on from whcih i can count added and removed words. I also save the comparison document to disk and that's where i have a problema. Most of the time this works fine but the last few months i got the following exception about 10 times (in a hudreds of comparisons) when i sabe the comparison doc:

    Message: CARABICABJADARABICAL (Roland DWX_Textos_EN_PT_Track_.doc)

    Source: Microsoft Word

    Method: Void SaveAs(System.Object ByRef, System.Object ByRef, System.Object ByRef, System.Object ByRef, System.Object ByRef, System.Object ByRef, System.Object ByRef, System.Object ByRef, System.Object ByRef, System.Object ByRef, System.Object ByRef, System.Object ByRef, System.Object ByRef, System.Object ByRef, System.Object ByRef, System.Object ByRef)

    Trace:    at Microsoft.Office.Interop.Word.DocumentClass.SaveAs(Object& FileName, Object& FileFormat, Object& LockComments, Object& Password, Object& AddToRecentFiles, Object& WritePassword, Object& ReadOnlyRecommended, Object& EmbedTrueTypeFonts, Object& SaveNativePictureFormat, Object& SaveFormsData, Object& SaveAsAOCELetter, Object& Encoding, Object& InsertLineBreaks, Object& AllowSubstitutions, Object& LineEnding, Object& AddBiDiMarks)   at Feedback_a_Tradutores.Classes.OfficeHandler.HandleWordDocument(String workFile, String revFile)   at Feedback_a_Tradutores.ViewModel.ProjectList.HandleDocumentCounts(FileInfo workFile, Result result, OfficeHandler oh, List`1 fails)   at Feedback_a_Tradutores.ViewModel.ProjectList.DocumentCalculations(Project project, Int32 location, IEnumerable`1 workPathList, List`1 revPathList, OfficeHandler oh, Results results, List`1 fails, Dispatcher dsp)   at Feedback_a_Tradutores.ViewModel.ProjectList.<>c__DisplayClassb.b__9(Object param0)

    For the life of me i can't figure out why this error happens or what CARABICABJADARABICAL means. Roland DWX_Textos_EN_PT_Track_.doc is the file name i was giving to the comparison doc in the case that reported the above eception. Obviously that name changes from iteration to iteration but the rest of the exception is always the same.

    Can anyone help me figure out what's causing this? i couldn't find that error anywhere online and i can't figureout what it even means. (CARABICABJADARABICAL)


    Luís Rodrigues



    • Edited by 537mfb Tuesday, October 29, 2013 10:57 AM Fix Exception text from copy-paste new line issues
    Tuesday, October 29, 2013 10:45 AM

All replies

  • Hi,

    What’s the version of Word you using? I failed to reproduce your issue on my side (Office 2013).
    Below is my code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Word=Microsoft.Office.Interop.Word;
    
    namespace ConsoleApplication6
    {
        class Program
        {
            static void Main(string[] args)
            {
                Word.Application word = new Word.Application();
                word.Visible = true;
                word.ChangeFileOpenDirectory(@"E:\Personal\");
                Word.Document OriginalDocument= word.Documents.Open("a.docx");
                Word.Document RevisedDocument = word.Documents.Open("Base64.docx");
                Word.Document differenceDocument= word.CompareDocuments(OriginalDocument, RevisedDocument, Word.WdCompareDestination.wdCompareDestinationNew, Word.WdGranularity.wdGranularityWordLevel, true, true, true, true, true, true, true, true, true, true, "", false);
                differenceDocument.SaveAs2(@"E:\Personal\Diff.docx");
                word.Quit();
            }
        }
    }
    

    Could you share some code snippet and sample word document with us through SkyDrive to reproduce the issue ?

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, October 31, 2013 3:27 AM
    Moderator
  • Hi Fei

    Reproducing is complicated as this doesn't happen every time - like i said about 10 times in hundreds (probably over a thousand) in the past few months. Which is why i only asked about the meaning of the error (CARABICABJADARABICAL) which to me is ust mumbo Jumbo meaningless scrambled letters.

    Here's My Code:

            public int[] HandleWordDocument(string workFile, string revFile)
            {
                Document revDoc = _wordDocs.Open(@revFile);
                var results = new int[4];
                results[3] = CountRevisions(revDoc, results);
                if ((results[1] == 0) && (results[0] == 0))
                {
                    Document workDoc = _wordDocs.Open(@workFile);
                    Document compDoc = _wordApp.CompareDocuments(workDoc, revDoc,
                                                                 WdCompareDestination.wdCompareDestinationNew,
                                                                 WdGranularity.wdGranularityWordLevel, false, true, true,
                                                                 true, true, true, true, true, true, true, "", true);
                    (workDoc).Close(WdSaveOptions.wdDoNotSaveChanges);
                    Marshal.ReleaseComObject(workDoc);
                    Directory.CreateDirectory(Path.Combine(Path.GetDirectoryName(revFile) ?? "", "TrackChanges"));
                    compDoc.SaveAs(
                        Path.Combine(Path.GetDirectoryName(revFile) ?? "", "TrackChanges",
                                     Path.GetFileNameWithoutExtension(revFile) + "_Track_.doc"),
                        WdSaveFormat.wdFormatDocument97);
                    results[3] = CountRevisions(compDoc, results);
    
                    compDoc.Close(WdSaveOptions.wdDoNotSaveChanges);
                    Marshal.ReleaseComObject(compDoc);
                }
                results[2] = revDoc.Words.Count;
                revDoc.Close(WdSaveOptions.wdDoNotSaveChanges);
                Marshal.ReleaseComObject(revDoc);
                return results;
            }

    The exception is trown in line compDoc.SaveAs( ......

    But like i said only on rare ocasions so na undertanding of the exception itself would be more valuable in this case

    Luis


    Luís Rodrigues

    Friday, November 1, 2013 10:30 AM