Yes you can. See this method from my Excel class:
function AlignCells(Excel, cellReference, horizAlign, autoFit)
try
Excel.Range(cellReference).Select;
Excel.Selection.HorizontalAlignment = horizAlign;
Excel.Selection.VerticalAlignment = 2;
if autoFit
Excel.Cells.EntireColumn.AutoFit;
end
Excel.Range('A1').Select;
catch ME
errorMessage = sprintf('Error in function AlignCells.\nError Message:\n%s', ME.message);
fprintf('%s\n', errorMessage);
WarnUser(errorMessage);
end
return;
end
Best Answer