Ver Mensaje Individual
  #2  
Antiguo 17-05-2007
Avatar de Gabo
[Gabo] Gabo is offline
Miembro Premium
 
Registrado: mar 2007
Ubicación: Murcia (España)
Posts: 684
Reputación: 18
Gabo Va por buen camino
Smile

Hola zidfrid, tal vez esto te pueda ayudar...


Código Delphi [-]
 
// CREO EL WORD
Variant word, doc;
try
{
    word = Variant::GetActiveObject("Word.Application");
    word.OleProcedure("Quit", false);
    word = Variant::CreateObject("Word.Application");
}catch(...){
    word = Variant::CreateObject("Word.Application");
}
word.OlePropertySet( "Visible", (Variant) true );
doc = word.OlePropertyGet("Documents");
// Creo la ruta completa al archivo *.doc
AnsiString archivo;
archivo = "C:\\archivo.doc");
// Si existe el archivo, lo abro.
if (FileExists(archivo))
{
    doc.OleFunction("Open", path, Unassigned, true);
}else{
    MessageBox(this->Handle, "El archivo no existe", "Error" , MB_APPLMODAL | MB_OK | MB_ICONERROR);
word.OleProcedure("Quit");
return;
}
// UNA VEZ ABIERTO ESCRIBO EN ÉL
try
{
  // CREO LOS ENCABEZADOS
  Variant Selection = word.OlePropertyGet("Selection");
  Variant Font = Selection.OlePropertyGet("Font");
  Variant Parrafo = Selection.OlePropertyGet("ParagraphFormat");
  Parrafo.OlePropertySet("Alignment","1");
  Font.OlePropertySet("Name","Monotype Corsiva");
  Font.OlePropertySet("Bold","1");
  Font.OlePropertySet("Size","13");
  Selection.OleProcedure("TypeText", "Hola a todos");
}catch(...){
  MessageBox(this->Handle, "Error al escribir en el archivo", "Error" , MB_APPLMODAL | MB_OK | MB_ICONERROR);
}
Responder Con Cita