Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 02-11-2005
Avatar de alt126
alt126 alt126 is offline
Miembro
 
Registrado: dic 2004
Posts: 171
Poder: 20
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:


Código:
  //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

Última edición por dec fecha: 02-11-2005 a las 13:09:56. Razón: ¡¡Encerrad el código fuente entre las etiquetas [CODE] ... [/CODE]!!
Responder Con Cita
  #2  
Antiguo 02-11-2005
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.278
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
Cita:
Empezado por 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.
Responder Con Cita
  #3  
Antiguo 02-11-2005
Avatar de alt126
alt126 alt126 is offline
Miembro
 
Registrado: dic 2004
Posts: 171
Poder: 20
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:


Código:
  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

Última edición por dec fecha: 02-11-2005 a las 13:08:51. Razón: ¡¡Encerrad el código fuente entre las etiquetas [CODE] ... [/CODE]!!
Responder Con Cita
  #4  
Antiguo 02-11-2005
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.278
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.
Responder Con Cita
  #5  
Antiguo 24-04-2007
zidfrid zidfrid is offline
Miembro
 
Registrado: abr 2007
Ubicación: buga valle colombia
Posts: 66
Poder: 18
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.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 22:00:12.


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
Copyright 1996-2007 Club Delphi