Falscher Variabletyp
-
Hi,
ich versuche, in einem Worddokument eine Tabelle zu erzeugen. Die Code ist wie folgendes beschrieben. Aber es ist immer problematisch, wenn ich ein String einsetze.(sieh letzte zeilen) Die Fehlermeldung ist "Falscher Variabletyp" für die Funktion "OlePropertySet(name, static_cast<TAutoArgsBase&>(args))".
Kann jemand die folgende Code auch mal kompilieren? und guck mal ob die gleiche Meldung kommt. Danke!
//--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { Variant wordApp; if (wordApp.IsEmpty()) { wordApp=Variant::CreateObject("Word.Application"); //wordApp.OlePropertySet("Visible", (Variant) true); } else { wordApp=GetActiveOleObject("Word.Application"); } if (wordApp.IsEmpty()) { ShowMessage("Unable to find Word application."); return; } //wordApp.OleProcedure("Add"); wordApp.OlePropertySet("Visible", (Variant) true); Variant wordDocuments = wordApp.OlePropertyGet("Documents"); // creates a new document wordDocuments.OleProcedure("Add"); Variant wordActiveDocument = wordApp.OlePropertyGet("ActiveDocument"); Variant wordTables = wordActiveDocument.OlePropertyGet("Tables"); Variant wordSelection = wordApp.OlePropertyGet("Selection"); Variant Range = wordSelection.OlePropertyGet("Range"); // inserts the table wordTables.OleProcedure("Add", Range, (Variant) 3, (Variant) 5); Variant wordTable1 = wordTables.OleFunction("Item", (Variant) 1); Variant wordCell = wordTable1.OleFunction("Cell", (Variant) 2, (Variant) 3 ); Variant wordRange = wordCell.OlePropertyGet("Range"); wordRange.OlePropertySet("Text", (Variant) "We are at 2/3"); //Hier ist immer problematisch }
-
dann lass doch "(Variant)" weg.
-
danke! Ohne "(Variant)" läuft es schon !