日期:2014-05-18  浏览次数:20792 次

求教Document.Activate这句话是什么意思???
这是我上一个帖子,里面说word打印时,就一直停在那里

其中源代码里面有一句doc.Activate();当我注掉这句话之后word打印恢复正常了。。。o(╯□╰)o

C# code

public void PrintWord(string path)
        {
            Object nothing = Missing.Value;
            Object falseValue = false;
            Object trueValue = true;
            Object pages = 1;
            Object paths = path;
            MSWord.ApplicationClass app = new Microsoft.Office.Interop.Word.ApplicationClass();
            app.Visible = false;
            MSWord.Document doc = app.Documents.Open(ref paths, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref trueValue, ref nothing, ref nothing, ref nothing, ref nothing);
            // doc.Activate();<-------------------------------------这里
            doc.PrintOut(ref trueValue, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref pages, ref nothing, ref nothing, ref falseValue, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing);
            doc.Close(ref falseValue, ref nothing, ref nothing);
            app.Quit(ref nothing, ref nothing, ref nothing);
            GC.Collect();
        }


看了msdn的Document.Activate 方法,备注里面只有调用 Activate 时,就好像用户单击该项一样,但不发生 Click 事件。这一句话

求教这句话为什么会导致我打印时打印队列停止,无法打印??????????????

------解决方案--------------------
难道doc.Activate();的执行是阻塞的?
------解决方案--------------------
为当前活动项,类似tab换活动标签了
------解决方案--------------------
LZ的结贴率是怎么弄的?