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:
active x - formatting excel cells from Matlab

Subject: active x - formatting excel cells from Matlab

From: Rich

Date: 4 May, 2010 14:52:04

Message: 1 of 2

Hi,
I am stumped on adding borders to excel cells (I can colour them ok!).
Any suggestions for what I'm doing wrong (snippet below)

mlrange='E1:F15'; % or similar

Excel = actxserver ('Excel.Application');
Excel.Workbooks.Open(filename);
TargetSheet = get(Excel.sheets,'item','A');
TargetSheet.Activate
ran = Excel.Activesheet.get('Range',mlrange);

ran.font.Color=hex2dec('FF0000'); % works fine
ran.BorderAround; %doesn't seem to do anything
 
%Other option that I could not get to work, not sure how to pass the arguments correctly...:
ran.Borders(xlEdgeBottom).LineStyle = 'xlContinuous'
ran.Borders(xlEdgeBottom).Weight = 'xlThick'

Thanks in advance!

Subject: active x - formatting excel cells from Matlab

From: Jon

Date: 26 Jan, 2011 14:23:03

Message: 2 of 2

"Rich" wrote in message <hrpcak$7km$1@fred.mathworks.com>...
> Hi,
> I am stumped on adding borders to excel cells (I can colour them ok!).
> Any suggestions for what I'm doing wrong (snippet below)
>
> mlrange='E1:F15'; % or similar
>
> Excel = actxserver ('Excel.Application');
> Excel.Workbooks.Open(filename);
> TargetSheet = get(Excel.sheets,'item','A');
> TargetSheet.Activate
> ran = Excel.Activesheet.get('Range',mlrange);
>
> ran.font.Color=hex2dec('FF0000'); % works fine
> ran.BorderAround; %doesn't seem to do anything
>
> %Other option that I could not get to work, not sure how to pass the arguments correctly...:
> ran.Borders(xlEdgeBottom).LineStyle = 'xlContinuous'
> ran.Borders(xlEdgeBottom).Weight = 'xlThick'
>
> Thanks in advance!

Try:
Sheet.get('Range','A:A').Border.Item('xlEdgeRight').LineStyle = 3

Also see:
http://msdn.microsoft.com/en-us/library/bb179328(v=office.12).aspx

Tags for 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