Hi!
I´m building a function that opens a workbook in Excel 2007 from a template. Then I want to copy the formatting from two rows, create new rows with the copied formats and insert data on those rows. This is what I´ve come up with so far:
The exSheet->Range("A1","B2"); part doesnt seem to work. I can only find C# examples and there they always use the get_Range function which doesnt work i C++/CLI. (Why?)Code:Microsoft::Office::Interop::Excel::Application^ exApp; Microsoft::Office::Interop::Excel::_Workbook^ exBook; Microsoft::Office::Interop::Excel::_Worksheet^ exSheet; Microsoft::Office::Interop::Excel::Range^ exRange; exApp = gcnew Microsoft::Office::Interop::Excel::ApplicationClass(); exBook = exApp->Workbooks->Open(lista->Dokumentmall,Type::Missing,Type::Missing, Type::Missing,Type::Missing,Type::Missing,Type::Missing,Type::Missing,Type::Missing, Type::Missing,Type::Missing,Type::Missing,Type::Missing,Type::Missing,Type::Missing); exSheet = (Microsoft::Office::Interop::Excel::Worksheet^)exBook->ActiveSheet; exRange = (Microsoft::Office::Interop::Excel::Range^)exSheet->Range("A1","B2"); //exRange->PasteSpecial(..) exApp->Visible = true;
I think that I might be able to use the Worksheet::Copy() and Worksheet::PasteSpecial() functions, or is there a way to use the Format Painter by code?
Anyway, I cant get it right from here.
Please help would be appreciated.
Regards
Matt


Reply With Quote
Bookmarks