Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / wxAutomationObject and MsWord

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. wxAutomationObject and MsWord
#2480
Posted by: 2003-08-19 17:57:52


Hi all,

I have a problem using wxAutomationObject with word and specifically
with the method CallMethod.

In the following there is a piece of the my code.

    wxVariant Res,PrintToFile,FileNameToPrint,OldPrinter;
    wxString loc_FileTmp=FilePath+"\\FileToPdf.tmp";
    wxAutomationObject AppObject;

    if (AppObject.CreateInstance("Word.Application"))
    {


Res=AppObject.CallMethod("Documents.Open",wxVariant(TxtChooseOrigFile->GetValue()));


        OldPrinter=AppObject.GetProperty("ActivePrinter");

        Res=AppObject.PutProperty("ActivePrinter",wxVariant("Fax"));

        PrintToFile=wxVariant(true,"PrintToFile");
        FileNameToPrint=wxVariant(loc_FileTmp,"OutputFileName");


Res=AppObject.CallMethod("ActiveDocument.Printout",PrintToFile,FileNameToPrint);



Res=AppObject.PutProperty("ActivePrinter",wxVariant(OldPrinter.GetString()));

        Res=AppObject.CallMethod("ActiveDocument.Close");
        Res=AppObject.CallMethod("Quit");
   }

At the end of the execution of the procedure, it appears a
warning: "ReleaseVariant: Unknown type".

I have noted that if I comment the lines:


Res=AppObject.CallMethod("ActiveDocument.Printout",PrintToFile,FileNameToPrint);


        Res=AppObject.CallMethod("ActiveDocument.Close");
        Res=AppObject.CallMethod("Quit");

the warning doesn't appear.

Could someone explain me where is the mistake?

Thanks in advance

Luca
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2023-1-27  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0