Reference an excel workbook that's already open

9 ビュー (過去 30 日間)
Brad Brown
Brad Brown 2015 年 5 月 27 日
コメント済み: Brad Brown 2015 年 6 月 1 日
Trying to reference a workbook that's already open rather than opening a new one. I can use activeX to connect to the existing server:
XLex = actxGetRunningServer('Excel.Application');
But having trouble referencing the workbook,tried a few different syntax, eg with 'Book3.xlsx'.
xlFILE = XLex.Workbooks.get('Workbooks','Book3.xlsx');
Or
XLex = get(XLex.Excel.ActiveWorkbook,'Workbooks', 'Book3.xlsx');
Neither of which will work! Thanks,

採用された回答

Al Dente
Al Dente 2015 年 5 月 27 日
actually
XLex.ActiveWorkbook
would give you a handle to the currently active workbook
you can even
XLex.ActiveWorkbook.Name
to see it's name. If more are open you can
for i = 1:XLex.Workbooks.Count
disp(XLex.Workbooks.Item(i).Name)
% XLex.Workbooks.Item(i) is a handle to the i-th item
end
  1 件のコメント
Brad Brown
Brad Brown 2015 年 6 月 1 日
This has helped, thanks amr!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by