Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 349
Default Basic Questions

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Basic Questions

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Basic Questions

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   Report Post  
Posted to microsoft.public.excel.programming
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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Basic Questions

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 200
Default Basic Questions

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Couple of basic questions from a beginner: [email protected] Excel Programming 2 March 6th 07 02:34 PM
Basic questions Maine begins Excel Discussion (Misc queries) 1 July 7th 06 06:45 PM
2 basic Excel questions for you pro's cjtj4700 Excel Discussion (Misc queries) 7 November 24th 05 07:31 PM
Very Basic Excel Object Questions BiilyJoeBob Excel Programming 5 June 20th 05 06:47 AM
EXCEL Visual Basic Questions Dean[_8_] Excel Programming 3 May 9th 05 09:03 PM


All times are GMT +1. The time now is 04:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"