"プリンタエラーが発生しました。" Word 2010でWindows 7のオートメーションを使用して印刷ジョブをプリンタに送信しようとすると、Word 2007のWindows XPボックスでも同じコードが正常に動作します.Windows 7またはWord 2010でエラーが発生しているかどうかはわかりません。Microsoft Word Interopの自動化FilePrintSetupエラー
すべてのヘルプは、私が指定したプリンタに印刷するプリンタパラメータ、呼び出しの仕事ではなく、アウトままにしておくと、私は
System.Reflection.TargetInvocationException was caught
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at PBP.ABC.Framework.Wrappers.Microsoft.Word.WordDocument.set_ActivePrinterName(String value) in
InnerException: System.Runtime.InteropServices.COMException
HelpLink=wdmain11.chm#24696
Message=There is a printer error.
Source=Microsoft Word
ErrorCode=-2146827168
InnerException:
以下のエラーを取得
using Microsoft.Office.Interop.Word;
.....
object oWordbasic = wordDoc.Application.WordBasic;
object[] argValues = new object[] { value, 1 }; //first arg is a printer name
String[] argNames = new String[] { "Printer", "DoNotSetAsSysDefault", };
//Error Here
oWordbasic.GetType().InvokeMember("FilePrintSetup", System.Reflection.BindingFlags.InvokeMethod, null, oWordbasic, argValues, null, null, argNames);
を高く評価しました。デフォルトのプリンタに印刷されます。
ありがとうございました。