LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 349
Default Setting columnwidths

I'm a bit new to this. I'm using C# with interop assmblies.

It does not let me set the Width property, anywhere. Either
Application.ActiveWindow or elsewhere. I get a runtime error.

And I'm not sure as to how I convert pixels to ColumnWidth, as in
range.ColumnWidth = this.usercontrol.width (pixels);

Only the worksheet.UsedRange is visible in my application. I want this to
fit exactly into the DSO Frame I have Excel displayed in, with no scrollbars
showing.

Thanks

"Jason Zischke" wrote:

NickHK

Thanks, that is just what I was looking for.

Jason

"NickHK" wrote:

Jason,
Something like this, converting from points to the units of ColumnWidth.
<From Help
One unit of column width is equal to the width of one character in the
Normal style
</From Help


Private Sub CommandButton1_Click()
Dim ColWidth As Single
Dim Factor As Single
Dim i As Long
'The range of columns you want to fit in the window
With Range("rngColumns")
ColWidth = ActiveWindow.UsableWidth / .Columns.Count
Factor = .Columns(1).Width / .Columns(1).ColumnWidth
For i = 1 To .Columns.Count
.Columns(i).ColumnWidth = ColWidth / Factor
Next
End With

End Sub

NickHK

"Jason Zischke" wrote in message
...
Dear NickHK

That sounds about that might work but how do do the column width in points

?

Jason

"NickHK" wrote:

Jason,
Depending what you are trying to achieve, Window.UsableWidth (in points)

may
be what you are after.
Then .Column.Width (in points) for each column that you wish to adjust.

NickHK

"Jason Zischke" wrote in

message
...
Hi all,

I've got one that has stumped me, I'm tring to set my column widths so
that
they fit to the window size however when using different screen sizes

and
different pixel sizes I can't get it working in all cases. I am

currently
using the function application.width to grab the window size, if

anyone
can
help me that would be greatly appreciated.

Jason Zischke






 
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
ColumnWidths property Tom Excel Programming 4 April 11th 06 09:33 AM
Combobox, Controlling columnwidths i curtain Claus[_3_] Excel Programming 0 December 5th 05 01:19 PM
PasteSpecial Paste:=ColumnWidths Arvi Laanemets Excel Programming 3 February 8th 05 01:46 PM
listbox.Columnwidths question Stuart[_5_] Excel Programming 1 September 21st 03 07:26 PM
Paste columnwidths in Xl2k problem Stuart[_5_] Excel Programming 3 September 4th 03 05:09 PM


All times are GMT +1. The time now is 06:17 AM.

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

About Us

"It's about Microsoft Excel"