Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Go Back   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Register FAQ Members List Calendar Guía de estilo Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02/11/2005
alt126's Avatar
alt126 alt126 is offline
Miembro
 
Join Date: Dec 2004
Posts: 171
Poder: 22
alt126 Va por buen camino
Automatizacion de word (generar documentos)

Hola de nuevo...tengo un problema a la hora de cambiar el color del texto cuando se inserta en word. El codigo es el siguiente:


Code:
  //VARIABLES
  
  Variant WordApp, WordDocs, WordDoc;
  
  //ABRIR UN DOCUMENTO EN BLANCO
  
  WordApp=Variant::CreateObject("Word.Application");
  WordApp.OlePropertySet("Visible", true); WordDocs=WordApp.OlePropertyGet("Documents");
  AnsiString szTxtFile=ExtractFilePath(Application->ExeName)+"\prueba.doc";
  WordDoc=WordDocs.OleFunction("Add");
  
  //INSERTAR TEXTO
  
  Variant Selection = WordApp.OlePropertyGet("Selection");
  Variant Font = Selection.OlePropertyGet("Font");
  Font.OlePropertySet("Name","Arial");
  Font.OlePropertySet("Bold","1");
  Font.OlePropertySet("Size","40");
  Font.OlePropertySet("Color",Edit1->Text);
  Selection.OleProcedure("TypeText", WideString("BEEEEEEEETIS"));
  Selection.OleProcedure("InsertDateTime", "dddd, dd MMMM yyyy", False);
  
  //AHI ME PETA A LA HORA DE METER EL COLOR...
  // SI PONGO wdColorRed,clRed,Red,ffffff,RGB(255,255,255)...TODO ESO PETA.
  //PERO SI PONGO UN NUMERO DE 0 HASTA 999999, FUNCIONA Y ME
  //DA COLORES.
LA REGLA DE COLORES ES LA SIGUIENTE:

0 - NEGRO
100 - MARRONCILLO
255 - ROJO
252525 - VERDOSILLO
505050 - AMARILLENTO


ALGUIEN PUEDE DECIRME ALGUNA REGLA LOGICA????

GRACIAS

Un saludo

Antonio

Last edited by dec : 02/11/2005 at 13:09. Reason: ¡¡Encerrad el código fuente entre las etiquetas [CODE] ... [/CODE]!!
Reply With Quote
  #2  
Old 02/11/2005
Neftali [Germán.Estévez]'s Avatar
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Join Date: Jul 2004
Location: Barcelona - España
Posts: 19,449
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Quote:
Originally Posted by alt126
LA REGLA DE COLORES ES LA SIGUIENTE:

0 - NEGRO
100 - MARRONCILLO
255 - ROJO
252525 - VERDOSILLO
505050 - AMARILLENTO

ALGUIEN PUEDE DECIRME ALGUNA REGLA LOGICA????
Esos son los números en decimal del color; Coge la calculadora de Windows, conviértelos a hexadecimal y obtendrás el valor que puedes probar en Delphi, por ejemplo:

$0 - NEGRO
$64 - MARRONCILLO
$FF - ROJO
$3D6AD - VERDOSILLO
$7B4DA - AMARILLENTO

Si colocas esos valores en Delphi, verás como obtienes esos colores, por lo tanto haciendo lo contrario puedes obtener el valor decimal del color que quieras.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Reply With Quote
  #3  
Old 02/11/2005
alt126's Avatar
alt126 alt126 is offline
Miembro
 
Join Date: Dec 2004
Posts: 171
Poder: 22
alt126 Va por buen camino
ahhhhhhhh!!

PERFECTO!!!

Unos cracks...

otraaaaaa preguntita...ahora quiero meter una tabla...estoy probando este codigo...pero ni me escribe nada en las celdas (deberia), ni me aparece si le doy una vista previa, aunque en diseño si aparece:


Code:
  Variant Selection = WordApp.OlePropertyGet("Selection");
  Variant selRange = Selection.OlePropertyGet("Range");
  Variant docTables = WordDoc.OlePropertyGet("Tables");
  docTables.OleFunction("Add", selRange, (Variant) 1, (Variant) 6);
  // Address the table
  Variant docTable1 = docTables.OleFunction("Item", (Variant) 1);
  // Update some cells
  Variant tableCell = docTable1.OleFunction("Cell", (Variant) 1,(Variant) 1);
  Variant cellRange = tableCell.OlePropertyGet("Range");
  cellRange.OlePropertySet("Text", (Variant) "1-1");
  tableCell = docTable1.OleFunction("Cell", (Variant) 1, (Variant) 2);
  cellRange = tableCell.OlePropertyGet("Range");
  cellRange.OlePropertySet("Text", (Variant) "1-2");
GRACIAS

Un saludo

Antonio

Last edited by dec : 02/11/2005 at 13:08. Reason: ¡¡Encerrad el código fuente entre las etiquetas [CODE] ... [/CODE]!!
Reply With Quote
  #4  
Old 02/11/2005
Neftali [Germán.Estévez]'s Avatar
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Join Date: Jul 2004
Location: Barcelona - España
Posts: 19,449
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Nueva pregunta, nuevo hilo.
Escribe un hilo nuevo con la referencia a la nueva pregunta, es mejor, más fácil de seguir luego y tendrás más probabilidades de que te contesten.
De todas formas y antes de ponerlo haz una búsqueda en los foros, me suena que éste tema (word y tablas) ya se ha hablado.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Reply With Quote
  #5  
Old 24/04/2007
zidfrid zidfrid is offline
Miembro
 
Join Date: Apr 2007
Location: buga valle colombia
Posts: 66
Poder: 20
zidfrid Va por buen camino
office 2k

hola amigos, tengo el siguiente problema. Trabajo con c++ buielder 6 y no se como sacarle una copia a un documento de word para despues modificarlo y almacenarlo en una determinada ruta, hago la aclaracion de que tampoco se como modificar este tipo de archivos, mejor dicho no se nada sobre este asunto y si alguien me pudiera colaborar le estaria muy agradecido.
Reply With Quote
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +2. The time now is 05:29.


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