Autor Beitrag
MysticMike
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 21



BeitragVerfasst: So 07.05.06 13:28 
Hi!

Ich hab folgendes Problem: ich speichere Schrifteigenschaften wie Farben, Style, ect. in einer Excel-Tabelle. Sieht dann so aus, dass z.B. in Zelle B2 als Farbe "clwhite" steht. Wenn ich es nach folgender Methode dann in Delphi zuweise führts zu einem Laufzeitfehler --> ungültige Varianttyp-Umwandlung.

ausblenden Delphi-Quelltext
1:
Form1.canvas.Font.Color := ExcelApp.Cells[2,2].Value;					


Weiß vielleicht jemand wie ich's richtig umwandle oder muss ich von Haus aus nen anderen Weg gehen?

thx Mystix

Ach ja: ExcelApp is folgendermaßen definiert:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
ExcelApp: OLEVariant;   


ExcelApp := CreateOleObject('Excel.Application'); //Excel Instanz erzeugen
ExcelApp.Workbooks.Open('.\Sprachausgabe.xls');
Mister X-Ray
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

Win XP, Win 2000
D7 Pers, D2005 Pers
BeitragVerfasst: So 07.05.06 14:52 
ich gehe mal davon aus dass du aus der excel-tabelle einen String zurück geliefert bekommst. Also müsstest du schreiben:

ausblenden Delphi-Quelltext
1:
Form1.canvas.Font.Color := StringToColor(ExcelApp.Cells[2,2].Value);					


Gruß
Mister X-Ray

_________________
Wissen ist Macht, aber nichts wissen macht nichts !
MysticMike Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 21



BeitragVerfasst: So 07.05.06 15:14 
Hi!

Danke für die schnelle Antwort! Mit der Farbzuweisung klappt's einwandfrei.

Gibts auch noch irgendwie eine Funktion wie ich einen String in einen Font.Style umwandeln kann?
MysticMike Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 21



BeitragVerfasst: So 07.05.06 15:18 
Ich denke

ausblenden Delphi-Quelltext
1:
if ExcelApp.Cells[y,x].Value = 'fsbold' then Font.style:= [fsbold];					


tuts auch, da ich ja nur zwischen Normal und Fett unterscheiden will.

greetz
Mister X-Ray
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

Win XP, Win 2000
D7 Pers, D2005 Pers
BeitragVerfasst: So 07.05.06 16:46 
ach ja, wenn du das ganze umgekehrt machen möchtest dann müsste das

ausblenden Delphi-Quelltext
1:
ExcelApp.Cells[2,2].Value := ColorToString(Form1.canvas.Font.Color)					


funktionieren.

Gruß
Mister X-Ray

_________________
Wissen ist Macht, aber nichts wissen macht nichts !
FloL
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29

Win XP
Delphi 2005
BeitragVerfasst: Mo 28.08.06 14:08 
Doofe Frage, aber als was muss man das in der uses-Liste definieren? Da das ja so nicht einfach funktionieren wird, will das auch nämlich auch machen ;)
Aber bekomme nen nen Fehler mit:
[Fehler] gebaeude.pas(580): E2003 Undefinierter Bezeichner: 'CreateOleObject'