How to open a document programatically

Top  Previous  Next

Here is some example code illustrating how to open a document file:

 

   CComPtr<Documents> pDocs = nullptr ;

   HRESULT hRes = pInvApp->get_Documents (&pDocs) ;

   if (FAILED(hRes) || (pDocs == nullptr)) {

       ShowCOMError(hRes,L"RunTest,get_Documents failed ");

       return ;

   }

 

   CComPtr<Document> pDoc;

   hRes = pDocs->Open (CComBSTR (L"C:\\PARTS\\MyPart.Ipt"),VARIANT_TRUE,&pDoc) ;

   if (FAILED(hRes) || (pDocs == nullptr)) {

       ShowCOMError(hRes,L"RunTest, Open failed ");

       return ;

   }

 

...

Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)