Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
COM: Get "type" of Excel workbook object

Subject: COM: Get "type" of Excel workbook object

From: Paul

Date: 9 May, 2013 18:01:14

Message: 1 of 2

The expression get(sh1,'type') returns xlWorksheet for a worksheet
object. However, there is no such type attribute for a workbook
object. What is the most reliable way to test for a workbook object,
ideally independent of Windows version and whether the host system is
32-bit or 64-bit. For that matter, it would be even more ideal if the
test method was independent of whether Matlab and Excel was 32-bit or
64-bit. I'm not sure if Excel actually comes in both bit-widths, but
the guiding idea is to write portable code that doesn't die just
because I forget to bring my laptop and end up using a colleague's
laptop.

Subject: COM: Get "type" of Excel workbook object

From: Philip Nienhuis

Date: 20 May, 2013 20:38:16

Message: 2 of 2

Paul wrote:
> The expression get(sh1,'type') returns xlWorksheet for a worksheet
> object. However, there is no such type attribute for a workbook
> object. What is the most reliable way to test for a workbook object,
> ideally independent of Windows version and whether the host system is
> 32-bit or 64-bit.

Exactly what do you want to test? workbook type is obviously impossible,
so what info do you want?

> For that matter, it would be even more ideal if the
> test method was independent of whether Matlab and Excel was 32-bit or
> 64-bit. I'm not sure if Excel actually comes in both bit-widths, but
> the guiding idea is to write portable code that doesn't die just
> because I forget to bring my laptop and end up using a colleague's
> laptop.

AFAIK 64 bit Excel cannot be accessed by 32 bit COM/ActiveX procedures
(read: e.g., 32-bit Matlab) and vice versa. This is indicated somewhere
on MS Technet.
Now I don't know if 64-bit Matlab has provisions to detect 32 or 64 bit
COM and automatically invoke the proper bit width routines for ActiveX
(I don't even know if it matters for Matlab).

If you want code to read/write Excel really independently of bit width
and platform you can use Java-based solutions like e.g., Apache POI. A
bit of work but not hard to do.
AFAIK Excel files on disk are identical whether written with 32 or 64
bit MS-Excel. (Is that the info you need?)

P.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us