Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Error al Abrir Plantilla RTF de Word desde delphi (https://www.clubdelphi.com/foros/showthread.php?t=68961)

ingabraham 17-07-2010 16:57:01

Error al Abrir Plantilla RTF de Word desde delphi
 
Me aparece el siguiente error:

Este archivo esta en uso por otra aplicacion
u otro usuario.
(:document and settings\...\normal.dot )
y aparece la ventana , guardar como
Nombre. normal
guardar como tipo. plantilla de documento

Mi codigo es el siguiente bt:
Código Delphi [-]

var
  Word1, Documento, t: OleVariant;  {   Word1, Documento: Variant;  }
Try
  
  (* Creas un objeto Word *)
  Word1 := CreateOleObject('Word.Application');
  SpeedButton1.Caption :='Generando el Registro..';

  Word1.Documents.Add('C:\BDATOS_TARJESOFT\ResolucionesTecnicos.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',' ');
 
  (* 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.';
 
  SpeedButton1.Enabled  := true;
  SpeedButton1.Caption  := ' .:: Visualizar Registro ::.' ;
 
   (* 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;
  Screen.Cursor := crDefault;
end;

ingabraham 27-07-2010 15:49:26

quien me ayuda.!!


La franja horaria es GMT +2. Ahora son las 19:21:09.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi