2017-05-01 14 views
7

I am cross-posting this question from Microsoft Community私はそこに何の応答も得ていないので、ここで誰かがこのことを明らかにすることができます。BUG:Word 2013 VSTOでヘッダーの画像を処理できない

VSTOを使用してドキュメントを処理するとき、Word 2013に固有の問題に気付きました。

文書は、そのレイアウトオプション「テキストの折り返しで」に設定されているヘッダーまたはフッターの画像が含まれているいずれかの「テキストの前に」または「テキストの背面」と:

Image with Layout Options set to "With Text Wrapping" with "Behind Text"

使い方私はここにREPROをアップロードし

The remote procedure call failed. (Exception from HRESULT: 0x800706BE) 

Word2013VstoImageFormattedInHeaderBug.zip

0123私は、ドキュメントを開き、図形を処理しようとすると、VSTOは、私は次の例外を取得しますここで
private static bool ShapesWithinGroup(Shape shape) 
{ 
    var result = false; 
    try 
    { 
     // shape.GroupItems throws the exception 
     if (shape.GroupItems != null && shape.GroupItems.Count > 0) 
     { 
      result = true; 
     } 
    } 
    catch (UnauthorizedAccessException) 
    { 
     // This shape is not in a group - ignore 
    } 
    catch (Exception exception) 
    { 
     var exceptionString = exception.BuildExceptionString(); 
     Console.WriteLine(exceptionString); 
     Console.WriteLine(exception.StackTrace); 
     //throw; 
    } 

    return result; 
} 

がいっぱい例外とスタックトレースです:コードの

関連作品はWordFieldEnumerator.csである

The remote procedure call failed. (Exception from HRESULT: 0x800706BE) 

    at Microsoft.Office.Interop.Word.Shape.get_GroupItems() 
    at Word2013VstoImageFormattedInHeaderBug.WordFieldEnumerator.ShapesWithinGroup(Shape shape) in C:\Users\QA\Desktop\Word2013VstoImageFormattedInHeaderBug\Word2013VstoImageFormattedInHeaderBug\WordFieldEnumerator.cs:line 170 
The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) 

    at Microsoft.Office.Interop.Word.Shape.get_TextFrame() 
    at Word2013VstoImageFormattedInHeaderBug.WordFieldEnumerator.ProcessShapes(IEnumerable`1 shapes) in C:\Users\QA\Desktop\Word2013VstoImageFormattedInHeaderBug\Word2013VstoImageFormattedInHeaderBug\WordFieldEnumerator.cs:line 124 
The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) 

    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) 
    at System.Runtime.InteropServices.CustomMarshalers.EnumeratorViewOfEnumVariant.MoveNext() 
    at System.Linq.Enumerable.<CastIterator>d__aa`1.MoveNext() 
    at Word2013VstoImageFormattedInHeaderBug.WordFieldEnumerator.ProcessShapes(IEnumerable`1 shapes) in C:\Users\QA\Desktop\Word2013VstoImageFormattedInHeaderBug\Word2013VstoImageFormattedInHeaderBug\WordFieldEnumerator.cs:line 90 
    at Word2013VstoImageFormattedInHeaderBug.WordFieldEnumerator.GetAllFields() in C:\Users\QA\Desktop\Word2013VstoImageFormattedInHeaderBug\Word2013VstoImageFormattedInHeaderBug\WordFieldEnumerator.cs:line 64 
    at Word2013VstoImageFormattedInHeaderBug.Program.LockDialogFields(Document document) in C:\Users\QA\Desktop\Word2013VstoImageFormattedInHeaderBug\Word2013VstoImageFormattedInHeaderBug\Program.cs:line 116 
    at Word2013VstoImageFormattedInHeaderBug.Program.PdfDocument(String documentFilePath) in C:\Users\QA\Desktop\Word2013VstoImageFormattedInHeaderBug\Word2013VstoImageFormattedInHeaderBug\Program.cs:line 60 

例外は関係なく、私はそれをキャッチしようとするか否かとスローされ、それクラッシュのWord 2013:

Event Viewer entry

このバグは、Word 2016では発生しません、シェイプを正常に処理できます。ただし、Office 2016へのアップグレードはオプションではありません。私はバグを修正するためにOffice 2013用の修正プログラムが必要だと考えています。

Word 2013でこれを行うには何かできますか?私は、Office 2013の複数の修復や再インストールを含め、多数の想定されていた修正を無駄に試しました。

+1

1. [ビデオドライバを更新しましたか](http://codeworks.it/blog/?p=136)? 2.アンチウィルス/ファイアウォールを無効にしても何か違いはありますか? 3. [wwlib.dll]の名前を変更しようとしましたか(https://answers.microsoft。com/en-us/office/forum/office_2010-word/word-2010-crashes-once-in-two-days-event-viewer/8b415426-3486-45c9-801a-01cbc114b184)とオフィス修理を行っていますか? 4.サーバーOSでこれを実行していませんか? 5. [Shapesで動作するコード](https://social.msdn.microsoft.com/Forums/office/en-US/b89dd0df-d46a-4fbd-97fe-d597fc292ceb/problem-setting-width-for-inlineshape) ?forum = worddev)は正しいですか? –

+0

@JeremyThompson 1.はい。 2.いいえ3.はい。 4.いいえ、Windows 10 64ビットバージョン1511(OSビルド10586.318)、Word 2013 32ビット15.0.4823.1000(MSO 15.0.4823.1000)、Office Standard 2013の一部。5.はい。バグはまだ発生し、Wordはクラッシュします。確認すべきことはありますか? –

+0

グループではないときに例外をキャッチするのではなく、シェイプの 'Type'をチェックしてもそれが起こりますか? – Chris

答えて

1

図形はページの任意の場所に配置できますが、常にテキストの固定範囲に添付されています。現在の範囲をアンカーされた図形を反復処理する前に選択すると、HRESULT 0x80010105 RPC_E_SERVERFAULT例外が解決されることがあります。あなたのGetAllFields()方法で

セレクト()それぞれProcessShapes()を呼び出す前に、ヘッダーとフッターの範囲。

foreach (HeaderFooter header in section.Headers) 
{ 
    if (header.LinkToPrevious) // || header.Index != WdHeaderFooterIndex.wdHeaderFooterFirstPage 
    { 
     continue; 
    } 

    header.Range.Select(); 

    // Add the fields in the header 
    fields.AddRange(header.Range.Fields.Cast<Field>()); 

    // Add the fields in the shapes in the header 
    var fieldsInShapes = ProcessShapes(header.Shapes.Cast<Shape>()); 
    fields.AddRange(fieldsInShapes); 
} 

foreach (HeaderFooter footer in section.Footers) 
{ 
    if (footer.LinkToPrevious) // || footer.Index != WdHeaderFooterIndex.wdHeaderFooterFirstPage 
    { 
     continue; 
    } 

    footer.Range.Select(); 

    // Add the fields in the footer 
    fields.AddRange(footer.Range.Fields.Cast<Field>()); 

    // Add the fields in the shapes in the footer 
    var fieldsInShapes = ProcessShapes(footer.Shapes.Cast<Shape>()); 
    fields.AddRange(fieldsInShapes); 
} 

これが役立つかどうかわかりませんが、 (私はWordの相互運用の専門家だ。)私は多くが後にクラスそれはエラーなしで可能な限りうまく機能し

//foreach (Section section in Document.Sections) 
      //{ 
      // foreach (HeaderFooter header in section.Headers) 
      // { 
      //  if (header.LinkToPrevious) // || header.Index != WdHeaderFooterIndex.wdHeaderFooterFirstPage 
      //  { 
      //   continue; 
      //  } 
      //  // Add the fields in the header 
      //  fields.AddRange(header.Range.Fields.Cast<Field>()); 

      //  // Add the fields in the shapes in the header 
      //  var fieldsInShapes = ProcessShapes(header.Shapes.Cast<Shape>()); 
      //  fields.AddRange(fieldsInShapes); 
      // } 

      // foreach (HeaderFooter footer in section.Footers) 
      // { 
      //  if (footer.LinkToPrevious) // || footer.Index != WdHeaderFooterIndex.wdHeaderFooterFirstPage 
      //  { 
      //   continue; 
      //  } 
      //  // Add the fields in the footer 
      //  fields.AddRange(footer.Range.Fields.Cast<Field>()); 

      //  // Add the fields in the shapes in the footer 
      //  var fieldsInShapes = ProcessShapes(footer.Shapes.Cast<Shape>()); 
      //  fields.AddRange(fieldsInShapes); 
      // } 
      //} 

WordFieldEnumeratorでこのコードをコメントし、それに取り組む

+0

範囲の代わりに図形に焦点を当てるならば、それは興味深いことです。私はこれを打ち明け、それがどのように進むのかを知らせます。応答していただきありがとうございます! –

+0

私はこれについて非常に興奮しています。私たちのQA部門は、Word 2013のこの修正を暫定的に承認しました!彼らは正式にバグを修正してマークする前に、いくつかのテストを実行するだけです。私はあなたに恩恵を授与します。私は(ダムは言うまでもなく)私がどのように完全に愚かであるかを表現することはできませんが、これはVSTOとCOMなので、これらの問題に対する解決法は左のフィールドから出てくると思われます。再度、感謝します! –

+0

こんにちは。私は多くの人が、Interop/VSTOのSDKを使いこなすのが難しいと感じていると思います。私はあなたとチームのためにもう一度正しい軌道に乗っていることを嬉しく思います。ハッピーコーディング!/Fredrik – Fredrik

0

。 エラーがシェイプ上にある場合、ヘッダーとフッターにアクセスできません。

+0

残念ながら、Word 2013がクラッシュする原因となるコードをコメントアウトすることは修正を構成しません。ごめんなさい。 –