필터 지우기
필터 지우기

word automation - adding / editing tables from matlab

조회 수: 1 (최근 30일)
tombola
tombola 2012년 3월 8일
Hi, I'm adding word tables using
MATLAB CODE
newtable = tableRange.ConvertToTable();
After this if I type
MATLAB CODE
newtable.Columns.Count
I get the correct answer, 22. BUT if I try and seelct a column via, say,
MATLAB CODE
newtable.Columns(1).Select();
the whole table is selected (!). Then, if I do
MATLAB CODE
col = newtable.Columns(1)
col has a type "columns" as if the index does not work and
MATLAB CODE
col = newtable.Columns(1).Count
agian returns 22.
Interestingly
MATLAB CODE
newtable.Columns(2).Select
Returns "Index exceeds matrix dimensions.".
It's almost like the index (1) etc is being ignores.
Can anyone help me on this please - for the best performance I really need to be able to quickly select entire columns without using MoveDown etc.
Tom

채택된 답변

Eric
Eric 2012년 3월 8일
I believe Columns is a Collection and that you need to do the following to access individual columns:
newtable.Columns.Item(1)
newtable.Columns.Item(2)
I believe Microsoft's COM interfaces do not support indexing into Collections directly with integers or strings the way VBA does.
Good luck, Eric
  댓글 수: 1
tombola
tombola 2012년 3월 9일
Brilliant, works perfectly thanks.
I owe you a virtual beer.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2012년 3월 8일
How big is newtable.Columns?
newtable.Columns
  댓글 수: 1
tombola
tombola 2012년 3월 8일
newtable.Columns
ans =
Interface.Microsoft_Word_12.0_Object_Library.Columns
newtable.Columns.Count
ans =
22
newtable.Columns(1)
ans =
Interface.Microsoft_Word_12.0_Object_Library.Columns
newtable.Columns(1).Count
ans =
22

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by