Ver Mensaje Individual
  #1  
Antiguo 11-10-2006
Carliviris Carliviris is offline
Miembro
 
Registrado: abr 2006
Posts: 93
Reputación: 19
Carliviris Va por buen camino
Imprimir en Word

Saludos a todos:

Estoy haciendo replace en un documento de word y todo esta muy bien. Lo unico que me falta es encontrar la manera de mandarlo a imprimir, opcion que se me ha hecho muy dificil de encontrar. Aca les dejo un ejemplo del codigo que estoy utilizando para hacer los replaces a ver si algunos de ustedes ha trabajado con este o tiene alguna idea de como hacer el mandato de imprimir. Todas las formas que creo que son me han resultado erroneas. Aqui esta:

Código Delphi [-] usesComObj;// Replace FlagstypeTWordReplaceFlags = set of (wrfReplaceAll, wrfMatchCase, wrfMatchWildcards);function Word_StringReplace(ADocument: TFileName; SearchString, ReplaceString: string; Flags: TWordReplaceFlags): Boolean;constwdFindContinue = 1; wdReplaceOne = 1; wdReplaceAll = 2; wdDoNotSaveChanges = 0; varWordApp: OLEVariant;beginResult := False;{ Check if file exists }if not FileExists(ADocument) then begin ShowMessage('Specified Document not found.'); Exit; end;{ Create the OLE Object }tryWordApp := CreateOLEObject('Word.Application');except on E: Exception do begin E.Message := 'Word is not available.'; raise;end;end;try{ Hide Word }WordApp.Visible := False;{ Open the document }WordApp.Documents.Open(ADocument);{ Initialize parameters}WordApp.Selection.Find.ClearFormatting; WordApp.Selection.Find.Text := SearchString; WordApp.Selection.Find.Replacement.Text := ReplaceString; WordApp.Selection.Find.Forward := True; WordApp.Selection.Find.Wrap := wdFindContinue; WordApp.Selection.Find.Format := False; WordApp.Selection.Find.MatchCase := wrfMatchCase in Flags; WordApp.Selection.Find.MatchWholeWord := False; WordApp.Selection.Find.MatchWildcards := wrfMatchWildcards in Flags; WordApp.Selection.Find.MatchSoundsLike := False; WordApp.Selection.Find.MatchAllWordForms := False; { Perform the search}if wrfReplaceAll in Flags thenWordApp.Selection.Find.Execute(Replace := wdReplaceAll)elseWordApp.Selection.Find.Execute(Replace := wdReplaceOne);{ Save word }WordApp.ActiveDocument.SaveAs(ADocument);{ Assume that successful }Result := True;{ Close the document }WordApp.ActiveDocument.Close(wdDoNotSaveChanges);finally{ Quit Word }WordApp.Quit; WordApp := Unassigned; end;end;
Responder Con Cita