A
antarikshv
I want to use VC++.Net 2005 to automate Microsoft word.I have checked
the code available online for C# but the code could not be translated
as it is to VC++ as the compiler was giving errors for the properties
could not be found. Below is the code where i am stuck,Please help.
Object ^ missing = System::Reflection::Missing::Value;
Object ^ EndODoc = "\\endofdoc";
Word::_Application ^ myWord;// = new Word.Application();
int return_Result = 0;
// Create a word object that we can manipulate
Word::Application ^ Word_App;
Word::_Document ^ Word_doc;
try
{
Word_App = gcnew Word::Application();
Word_doc = gcnew Word:
ocument();
}
catch (Exception ^ e1)
{
return_Result = 1;
//goto Exit;
}
Word::AutoCorrect ^ autocorrect = Word_App->AutoCorrect;
Word::AutoCorrectEntries ^ autoEntries = autocorrect-
String ^ theEnd = "\nThe End";
autoEntries->Add("Introduction", "Introduction");
Word:
ocuments ^ Docs = Word_App->Documents;
Word_App->Visible = true;
Word::_Document ^ my_Doc = (Word::_Document ^)Word_doc;
Word_doc = Docs->Add(missing,missing,missing,missing);
Object ^start;
Object ^end;
Word::Range ^range = Word_doc->Range( missing, missing);
Word:
aragraph ^ pgs;// = gcnew Word:
aragraph();
pgs = Word_doc->Content->Paragraphs->Add(missing);
pgs->Range->Text = "Helllo";
(The Range property is present for the Paragraph class but its not
accessible.)
the code available online for C# but the code could not be translated
as it is to VC++ as the compiler was giving errors for the properties
could not be found. Below is the code where i am stuck,Please help.
Object ^ missing = System::Reflection::Missing::Value;
Object ^ EndODoc = "\\endofdoc";
Word::_Application ^ myWord;// = new Word.Application();
int return_Result = 0;
// Create a word object that we can manipulate
Word::Application ^ Word_App;
Word::_Document ^ Word_doc;
try
{
Word_App = gcnew Word::Application();
Word_doc = gcnew Word:
![Big Grin :D :D](/styles/default/custom/smilies/grin.gif)
}
catch (Exception ^ e1)
{
return_Result = 1;
//goto Exit;
}
Word::AutoCorrect ^ autocorrect = Word_App->AutoCorrect;
Word::AutoCorrectEntries ^ autoEntries = autocorrect-
Entries;
String ^ theEnd = "\nThe End";
autoEntries->Add("Introduction", "Introduction");
Word:
![Big Grin :D :D](/styles/default/custom/smilies/grin.gif)
Word_App->Visible = true;
Word::_Document ^ my_Doc = (Word::_Document ^)Word_doc;
Word_doc = Docs->Add(missing,missing,missing,missing);
Object ^start;
Object ^end;
Word::Range ^range = Word_doc->Range( missing, missing);
Word:
![Stick Out Tongue :P :P](/styles/default/custom/smilies/tongue.gif)
![Stick Out Tongue :P :P](/styles/default/custom/smilies/tongue.gif)
pgs = Word_doc->Content->Paragraphs->Add(missing);
pgs->Range->Text = "Helllo";
(The Range property is present for the Paragraph class but its not
accessible.)