Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am programming Excel in a DSP Framer using C#. Since C# is a more strongly
typed language than VB, it is hard for me to translate some of the VB that I've seen. UsedRange.Columns How would I parse through each column. I do not see and Excel.Column object. What does range.Columns return? Is it a collection (of what). I want to resize the used range, the only part of the worksheet that is visible to be the size of the frame, as in Excel.Application.Width - this.frame.width. It would let me set the width property, and the ColumnWidth proprty is not expressed in pixels. It seems simple enough, but how is it done? The ChangeEvent returns a range with dollar signes, like $A$1. What do the dollar signs mean? How do I use them? I don't see a re-size event for Excel? When I re-size the frame control, I need to re-size Excel. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
P.S. "$A$1" is an absolute cell reference. "A1" is a relative cell
reference. For example, if you copy a formula in cell B1 containing "$A $1" to cell B2, the formula in B2 will reference A1. If you copy a formula in cell B1 containing "A1" to cell B2, the formula in B2 will reference A2 instead. I don't know why a Change event uses $'s, but believe it's a given. Hth, Merjet |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How do I enumerate through all columns in the usedrange using C#?
Here is a way it can be done in VBA. For iCt = 1 To Sheet1.UsedRange.Columns.Count Sheet1.UsedRange.Columns(iCt).ColumnWidth = 5 Next iCt I don't know enough C# to answer this or your other questions. I haven't used OfficeDataSourceObject, but glean it's for working with a database (Access, ODBC, etc.) Hth, Merjet |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Peter wrote:
.. . . What does range.Columns return? Is it a collection (of what). . . . Range("A1:D10").Columns.Address returns $A$1:$D$10. It is a collection of columns; i.e., Range("A1:D10").Columns(2).Address returns $B$1:$B$10; Range("A1:D10").Columns(2)(2) returns $C$1:$C$10; Range("A1:D10").Columns(2).Cells(2) returns $B$2. Alan Beban |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Couple of basic questions from a beginner: | Excel Programming | |||
Basic questions | Excel Discussion (Misc queries) | |||
2 basic Excel questions for you pro's | Excel Discussion (Misc queries) | |||
Very Basic Excel Object Questions | Excel Programming | |||
EXCEL Visual Basic Questions | Excel Programming |