Copy and Paste Excel Sheet into New WorkBook

I have two excel files:
file1.xlsx
file2.xlsx
file1.xlsx has a formatted sheet that I want to copy and paste into sheet 2 of a new workbook: file2.xlsx.
Basically I want to copy a sheet from one book to another.
This is what I have so far( I have tried to modify what I've found from other Threads)
Excel = actxserver('excel.application');
wkbk = Excel.Workbooks.Open('file1');
wksheet = wkbk.Worksheets.Item('Sheet1');
wksheet.Copy(wksheet);
wkbk = Excel.Workbooks.Open('file2.xlsx');
newSheet=wkbk.Worksheets.Item('Sheet2');
newSheet.Name='140C';
wkbk.Save
Excel.Quit

3 件のコメント

Jan
Jan 2019 年 7 月 19 日
[MOVED from flags] Flagged as Unclear by Brian Peoples on 17 Jul 2019 at 5:42.
This answer would be appreciated!!
Jan
Jan 2019 年 7 月 19 日
@Brian: The thread is old and the OP forgot to ask a question. So which answer do you mean?
Most likely it is the best idea to open your own question and to add the details there.
Mario Chiappelli
Mario Chiappelli 2019 年 7 月 19 日
Something like this is best suited for VBA, I would recommend exploring how to use that.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeData Export to MATLAB についてさらに検索

質問済み:

2015 年 7 月 7 日

回答済み:

2019 年 9 月 30 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by