Excel

Please could anybody help with this code?

Variant vFileName, vXLWorkbooks, file;

Dopen1->Execute();
file=Dopen1->FileName;

vFileName = file;
vMSExcel = Variant::CreateObject("Excel.Application");
vMSExcel.OlePropertySet("Visible", true);
vXLWorkbooks = vMSExcel.OlePropertyGet("Workbooks");
vXLWorkbook = vXLWorkbooks.OleFunction("Open", vFileName);

if i wrote instead of [italic]vFileName = file;[/italic]

vFileName = "C:\Documents and Settings\Slimo\Desktop\projekty\databaza\db1.xls";

its no problem

thanks

Comments

  • : Please could anybody help with this code?
    :
    : Variant vFileName, vXLWorkbooks, file;
    :
    : Dopen1->Execute();
    : file=Dopen1->FileName;
    :
    : vFileName = file;
    : vMSExcel = Variant::CreateObject("Excel.Application");
    : vMSExcel.OlePropertySet("Visible", true);
    : vXLWorkbooks = vMSExcel.OlePropertyGet("Workbooks");
    : vXLWorkbook = vXLWorkbooks.OleFunction("Open", vFileName);
    :
    : if i wrote instead of [italic]vFileName = file;[/italic]
    :
    : vFileName = "C:\Documents and
    : Settings\Slimo\Desktop\projekty\databaza\db1.xls";
    :
    What compiler error do you get? If you get something like 'Cannot convert 'const char *' to 'AnsiString' you need to change the code to this:
    [code]
    vFileName = file.c_str();
    [/code]

    See ya,




    bilderbikkel
  • Thanks it works

  • Hi

    I have another problem
    i open a file
    if ((handle_cfg = FileOpen("config.slm", fmOpenReadWrite)) == -1)
    ShowMessage("Program Error - config.slm corrupted");

    no problem with this

    but if i try to write there something

    FileSeek(handle_cfg,0,0);
    if ((amountread = FileWrite(handle_cfg, Eskupina->Text.c_str() ,Eskupina->Text.Length() )) == -1)
    ShowMessage("Saving Error");
    else
    ShowMessage("Saved Succesfuly");

    it always return -1 = error

    thanks


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories