Board index » delphi » Change COLUMNWIDTH in Excel

Change COLUMNWIDTH in Excel

ExcelWorksheet.Columns.ColumnWidth := 20;

Changes the column width in the entire worksheet - but how do I change just
one specific column ?

Uffe Sturegren

 

Re:Change COLUMNWIDTH in Excel


OleVariant(WorksheetVar).Columns['B'].ColumnWidth := 60;

Rgds Tim

Quote
> Changes the column width in the entire worksheet - but how do I change
just
> one specific column ?

Re:Change COLUMNWIDTH in Excel


I cannot get this to work;

OleVariant(ExcelWorksheet).Columns['A'].ColumnWidth := 6;
Error: "Invalid Typecast"

And if I try ;
ExcelWorksheet.Columns['A'].ColumnWidth := 6;
Error: "Class does not have a default property"

Uffe Sturegren

Tim Jarvis skrev i meddelandet <7u66tj$82...@forums.borland.com>...

Quote
>OleVariant(WorksheetVar).Columns['B'].ColumnWidth := 60;

>Rgds Tim

>> Changes the column width in the entire worksheet - but how do I change
>just
>> one specific column ?

Re:Change COLUMNWIDTH in Excel


US <nob...@hotmail.com> schrieb im Beitrag
<7u731t$g...@forums.borland.com>...

Quote
> I cannot get this to work;

> OleVariant(ExcelWorksheet).Columns['A'].ColumnWidth := 6;
> Error: "Invalid Typecast"

> And if I try ;
> ExcelWorksheet.Columns['A'].ColumnWidth := 6;
> Error: "Class does not have a default property"

Try following:

ExcelWorksheet.Cells.Item[1,1].EntireColumn.ColumnWidth := 6;
--
cu
Mario

Other Threads