Thread: Basic Questions
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Peter Peter is offline
external usenet poster
 
Posts: 349
Default Basic Questions

Thanks, that's a helpful start. If I want to go through each column in the
worksheet, I tried (C#):

foreach(OfficeDataSourceObject oo in (OfficeDataSourceObject)
worksheet.Columns)
{
string x=oo.ToString();
}

But get the compiler error.

foreach statement cannot operate on variables of type
'Microsoft.Office.Core.OfficeDataSourceObject' because
'Microsoft.Office.Core.OfficeDataSourceObject' does not contain a public
definition for 'GetEnumerator'

How do I enumerate through all columns in the usedrange using C#?

Also I mistyped my previous post. If I try to set application.Width = 400.0,
I get an exception: e.Message = "Exception from HRESULT: 0x800A03EC". I'm
using interop.Excel assemblies, not Office.Tools.Excel. Should I switch?

"merjet" wrote:

Columns is a member of Application, OfficeDataSourceObject, Range,
Worksheet. Excel is a Library.

You can only resize UsedRange by using more or fewer cells. It is a
read-only property.

From Excel Help, one unit of ColumnWidth is equal to the width of one

character in the Normal style. For proportional fonts, the width of
the character 0 (zero) is used.

When Application.WindowState = xlNormal, it can be resized as follows
(change numbers to suit).
Application.Left = 193.75
Application.Top = 1.75
Application.Width = 574.5
Application.Height = 552.75

Hth,
Merjet