CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Threaded View

  1. #2
    Join Date
    Aug 2002
    Location
    Kerala
    Posts
    1,183

    Re: Password check for DOC files

    You did not say what version what framework etc. !!! .NET or MFC ???

    Assuming the latest VC version and default framework ( VS2008 and .NET)

    Code:
    using namespace System;
    using namespace Reflection;
    int main(array<System::String ^> ^args){
          Word::Application^ wdApp = gcnew Word::Application();
          Object^% file = gcnew String("c:\\Test\\doc1.doc");
          Object^% pwd = gcnew String("opensesame");
          Word::Document^ wdDoc;
          wdApp->Visible = true; 
          try {
          wdDoc = wdApp->Documents->Open( file , Missing::Value, 
                                          Missing::Value, Missing::Value, 
                                          pwd, Missing::Value, 
                                          Missing::Value, Missing::Value, 
                                          Missing::Value, Missing::Value,
                                          Missing::Value, Missing::Value, 
                                          Missing::Value, Missing::Value, 
                                          Missing::Value, Missing::Value 
                                          );
          }
          catch(Exception^ e) {
            Console::WriteLine(e->Message); 
         }
          if(wdDoc != nullptr) {
            Console::WriteLine("The document was opened successfully!");
          } 
          Console::ReadLine();  
          return 0;
    }
    Last edited by Sahir; February 24th, 2008 at 06:00 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured