Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Servers (https://www.clubdelphi.com/foros/forumdisplay.php?f=9)
-   -   Poner El Cursor Al Final Del Documento (https://www.clubdelphi.com/foros/showthread.php?t=48322)

perlacbr 21-09-2007 16:23:07

Poner El Cursor Al Final Del Documento
 
Hola a todos

Necesito PONER EL CURSOR AL FINAL DEL DOCUMENTO
Hace dias que estoy tratando de resolver el problema y no lo logro, ya revise todos los post que encontre con el tema y tampoco me resuelven, trabajo con DELPHI5 y exporto el documento con los componentes de la paleta servers: TWordApplication;TWordDocument.

Lo que tengo que hacer es enviar varias tablas a word segun el resultado de una consulta, cuando envio la primera el cursor se me queda en la primera celda y yo necesito enviarlo al final del documento para insertar la siguiente tabla y asi varias veces


Aqui les envio mi codigo, si alguien puede revisarlo y decirme que estoy haciendo mal.

Muchas gracias

TMain = class(TForm)
WordApplication1: TWordApplication;
Doc: TWordDocument;
ParaFmt: TWordParagraphFormat;
WordFont1: TWordFont;
..............
end;


procedure TMain.SpeedButton1Click(Sender: TObject);
var
S: Selection;
WordTable: Table;
RowCount, ColCount: Integer;
RowIndex, ColIndex: Integer;


begin


WordApplication1.Connect;
WordApplication1.Visible := True;

Doc.ConnectTo(WordApplication1.Documents.Add(EmptyParam, EmptyParam));

{Insertamos un texto al comienzo de la pagina con un formato dado}
S := WordApplication1.Selection;
WordFont1.ConnectTo(S.Font);
S.Font.Size := 16;
S.Font.Name := 'arial';
S.Font.Bold := integer(True);
S.Font.ColorIndex:=09;
S.ParagraphFormat.Alignment := wdAlignParagraphCenter; //texto centrado
S.TypeText('Solicitud de Suministros');
S.TypeParagraph;
S.TypeParagraph;

//fecha impresion
S.Font.Size := 11;
S.ParagraphFormat.Alignment := wdAlignParagraphRight; //texto derecha
S.TypeText('Fecha Impresion:');
S.TypeParagraph; //cambio de linea
S.TypeParagraph;//inserto una linea
S.ParagraphFormat.Alignment := wdAlignParagraphLeft; //texto izq
doc.Application.Selection.Range.set_text('Esto es una Prueba');//aqui inserto un texto
try
RowCount := 16;
ColCount := 5;/
WordTable := doc.Tables.Add(S.Range, RowCount + 1, ColCount);
for ColIndex := 1 to ColCount do
begin
WordTable.Cell(1, ColIndex).Range.Font.Bold := 1;
WordTable.Cell(1, ColIndex).Range.Text := 'mi prueba';
WordTable.Cell(1, ColIndex).Range.Paragraphs.Alignment :=wdAlignParagraphCenter;
end;
RowIndex := 2;
while RowIndex <=16 do
begin
for ColIndex :=1 to ColCount do
WordTable.Cell(RowIndex, ColIndex).Range.Text := 'items';
Inc(RowIndex);
end;
finally
end;
//aqui es donde debo poner el cursor al final y volver a insertar otra tabla
//he probado todas estas, por supuesto, por separado(una o la otra y nada)
Doc.Application.Selection.End_;//ya probe con esto pero nada, no me da error pero no se mueve el cursor
Doc.Application.Selection.endkey;// error [Error]Not enough actual parameters

end;

saludos

rebollón 08-10-2007 12:36:04

A mi me funciona esto:

WordApp.ActiveWindow.Selection.EndKey(FinalDelDocumento, EmptyParam);

Donde finaldeldocumento está definida como OleVariant y al inicio del programa inicializo como:

FinalDelDocumento:= wdStory;

perlacbr 16-10-2007 23:45:45

Hola rebollón

No habia dado acuse de recibo porque no tenia Internet

muchas gracias por responder

eso que me dices ya lo habia probado y nada
Lo que al final me resulto es lo que sigue por si le sirve a alguien

saludos


var
wdGoToPage, wdGoToLast: OleVariant;
............
begin
............

// ir al final del documento
wdGoToPage := 3;
wdGoToLast := -1;
WordApplication1.Selection.GoTo_wdGotoPage,wdGoToLast,EmptyParam,EmptyParam);
.........
end


La franja horaria es GMT +2. Ahora son las 06:13:28.

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