Ver Mensaje Individual
  #1  
Antiguo 08-10-2010
Avatar de ingabraham
ingabraham ingabraham is offline
Miembro
 
Registrado: ago 2007
Posts: 614
Reputación: 17
ingabraham Va por buen camino
Problema al exportar datos a platilla rtf en word 2003

hola tengo el sg codigo para exportar unos datos a una plantilla .rtf en word.

Código Delphi [-]

Try
   
  //Crear Carpeta
    carpeta:= 'C:\BDATOS_TARJESOFT\Tmp';
   if Not DirectoryExists(Carpeta) Then
    CreateDir(Carpeta);

  SpeedButton1.Caption :='Generando el Registro.';
  (* Creas un objeto Word *)
  Word1 := CreateOleObject('Word.Application');
  SpeedButton1.Caption :='Generando el Registro..';
     Word1.Documents.Add('C:\BDATOS_TARJESOFT\ResolucionesTecnicosRegenciaFarmacia.rtf')
    SpeedButton1.Caption :='Generando el Registro...';
  Documento := Word1.Documents.Item(1);
  SpeedButton1.Caption :='Enviando Parametros a Word..';

 (* Asignas valores a los campos *)
    if  EdNroRegistro.Text <> '' then
      Documento.Variables.Add('NRESOLUCION', EdNroRegistro.Text)
    else
      Documento.Variables.Add('NRESOLUCION',' ');

    if   EdNombre1.Text <> '' then
      Documento.Variables.Add('NOMBRES', EdNombre1.Text)
    else
      Documento.Variables.Add('NOMBRES',' ');

    if  EdCedula.Text <> '' then
      Documento.Variables.Add('CEDULA', EdCedula.Text)
    else
      Documento.Variables.Add('CEDULA',' ');

  (* Actualizar campos *)
    Documento.Fields.ToggleShowCodes;
    Documento.Fields.Update;

  NuevoArchivo := 'C:\BDATOS_TARJESOFT\Tmp\ArchivoTmp'+IntToStr(DMDatos.ObtenerNroConsecutivo)+'.rtf';
  Word1.ActiveDocument.SaveAs(NuevoArchivo);
  DMDatos.IncrementarNroConsecutivo;

  SpeedButton1.Caption :='Abriendo Word...';
  (* Fuerzas a mostrar el contenido del campo *)
  Word1.ActiveWindow.View.ShowFieldCodes := false;
  SpeedButton1.Caption :='Archivo Completado.';
 
 
 
   (* Ver Word*)
  Word1.Visible := true;

 except
   on E:Exception do
   begin
    ShellExecute(Handle, nil, 'tskill', 'winword', nil, sw_hide);
    messagedlg(' Verifique sus datos que esten correctamente '+e.Message,mtWarning,[mbok],0);
  end;
end;

problemas, luego de cerrar el archivo me parece esta ventana.

1. error word
[ ] recuperar trabajo y reiniciar word.


2. aveces me aparece guardar plantilla normal.
__________________
Enseñar es la virtud de un sabio.
Responder Con Cita