Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default How to change column size in VB6 and Excel 2002

Hello.

Using VB6.0 and Excel 2002. I'm trying to change the column width of a
column before saving the workbook. I can do other changes to the worksheet,
like fonts and values etc., but it won't change the columnwidth.

I tried these statements and none of them work:
oSheet.Range("A1").Columns.ColumnWidth = 5.75
oSheet.Range("A1").ColumnWidth = 5.75
oSheet.Columns("A:A").ColumnWidth = 5.75

oSheet.Columns("A").Select
Selection.ColumnWidth = 5.75

Does anybody know how to do this?

Any help would be gratefully appreciated.

Thanks,
Tony
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default How to change column size in VB6 and Excel 2002

On Jan 15, 8:21*pm, Tony Girgenti wrote:
Hello.

Using VB6.0 and Excel 2002. *I'm trying to change the column width of a
column before saving the workbook. *I can do other changes to the worksheet,
like fonts and values etc., but it won't change the columnwidth.

I tried these statements and none of them work:
* * * * oSheet.Range("A1").Columns.ColumnWidth = 5.75
* * * * oSheet.Range("A1").ColumnWidth = 5.75
* * * * oSheet.Columns("A:A").ColumnWidth = 5.75

* * * * oSheet.Columns("A").Select
* * * * Selection.ColumnWidth = 5.75

Does anybody know how to do this?

Any help would be gratefully appreciated.

Thanks,
Tony


Try:

Sheets("oSheet").Columns("A:A").ColumnWidth = 5.75
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default How to change column size in VB6 and Excel 2002

Hello GTVT06.

I'm getting Subscript out of range when i try your code.

Thanks,
Tony

"GTVT06" wrote:

On Jan 15, 8:21 pm, Tony Girgenti wrote:
Hello.

Using VB6.0 and Excel 2002. I'm trying to change the column width of a
column before saving the workbook. I can do other changes to the worksheet,
like fonts and values etc., but it won't change the columnwidth.

I tried these statements and none of them work:
oSheet.Range("A1").Columns.ColumnWidth = 5.75
oSheet.Range("A1").ColumnWidth = 5.75
oSheet.Columns("A:A").ColumnWidth = 5.75

oSheet.Columns("A").Select
Selection.ColumnWidth = 5.75

Does anybody know how to do this?

Any help would be gratefully appreciated.

Thanks,
Tony


Try:

Sheets("oSheet").Columns("A:A").ColumnWidth = 5.75

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to change column size in VB6 and Excel 2002

oSheet.Columns("A:A").ColumnWidth = 5.75

or

oSheet.Range("A1").Entirecolumn.ColumnWidth = 5.75

Tony Girgenti wrote:

Hello GTVT06.

I'm getting Subscript out of range when i try your code.

Thanks,
Tony

"GTVT06" wrote:

On Jan 15, 8:21 pm, Tony Girgenti wrote:
Hello.

Using VB6.0 and Excel 2002. I'm trying to change the column width of a
column before saving the workbook. I can do other changes to the worksheet,
like fonts and values etc., but it won't change the columnwidth.

I tried these statements and none of them work:
oSheet.Range("A1").Columns.ColumnWidth = 5.75
oSheet.Range("A1").ColumnWidth = 5.75
oSheet.Columns("A:A").ColumnWidth = 5.75

oSheet.Columns("A").Select
Selection.ColumnWidth = 5.75

Does anybody know how to do this?

Any help would be gratefully appreciated.

Thanks,
Tony


Try:

Sheets("oSheet").Columns("A:A").ColumnWidth = 5.75


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default How to change column size in VB6 and Excel 2002

What exactly do you have the variable osheet equal to?
Better yet, is it a variable or a sheet name?

"Tony Girgenti" wrote:

Hello GTVT06.

I'm getting Subscript out of range when i try your code.

Thanks,
Tony

"GTVT06" wrote:

On Jan 15, 8:21 pm, Tony Girgenti wrote:
Hello.

Using VB6.0 and Excel 2002. I'm trying to change the column width of a
column before saving the workbook. I can do other changes to the worksheet,
like fonts and values etc., but it won't change the columnwidth.

I tried these statements and none of them work:
oSheet.Range("A1").Columns.ColumnWidth = 5.75
oSheet.Range("A1").ColumnWidth = 5.75
oSheet.Columns("A:A").ColumnWidth = 5.75

oSheet.Columns("A").Select
Selection.ColumnWidth = 5.75

Does anybody know how to do this?

Any help would be gratefully appreciated.

Thanks,
Tony


Try:

Sheets("oSheet").Columns("A:A").ColumnWidth = 5.75



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default How to change column size in VB6 and Excel 2002

i tested below in VB6.0 and Excel2003. it could change the column width of a
column, and almost your code also could change the width of column.

Sub testVB6()
Dim oApp As Excel.Application
Dim oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet
Set oApp = New Excel.Application

oApp.Visible = True
On Error Resume Next
Set oBook = oApp.Workbooks.Open("C:\testsample.xls")
If oBook Is Nothing Then
Set oBook = oApp.Workbooks.Add
oBook.SaveAs "C:\testsample.xls"
End If

Set oSheet = oBook.Worksheets(1)
oSheet.Columns("A").ColumnWidth = 5.75
oSheet.Range("A1") = oSheet.Columns("A").ColumnWidth

oApp.DisplayAlerts = False
oBook.Close SaveChanges:=True
Set oSheet = Nothing
Set oBook = Nothing
oApp.Quit
Set oApp = Nothing
End Sub

keiji

"Tony Girgenti" wrote in message
...
Hello.

Using VB6.0 and Excel 2002. I'm trying to change the column width of a
column before saving the workbook. I can do other changes to the
worksheet,
like fonts and values etc., but it won't change the columnwidth.

I tried these statements and none of them work:
oSheet.Range("A1").Columns.ColumnWidth = 5.75
oSheet.Range("A1").ColumnWidth = 5.75
oSheet.Columns("A:A").ColumnWidth = 5.75

oSheet.Columns("A").Select
Selection.ColumnWidth = 5.75

Does anybody know how to do this?

Any help would be gratefully appreciated.

Thanks,
Tony


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default How to change column size in VB6 and Excel 2002

Hello JLGWhiz.

I used the code posted by kounoike in this thread. It works fine except
that it doesn't change the column width. I makes all of the other changes as
far as values and fonts, etc., but not the column width.

Can this really be done?

Thanks,
Tony

"JLGWhiz" wrote:

What exactly do you have the variable osheet equal to?
Better yet, is it a variable or a sheet name?

"Tony Girgenti" wrote:

Hello GTVT06.

I'm getting Subscript out of range when i try your code.

Thanks,
Tony

"GTVT06" wrote:

On Jan 15, 8:21 pm, Tony Girgenti wrote:
Hello.

Using VB6.0 and Excel 2002. I'm trying to change the column width of a
column before saving the workbook. I can do other changes to the worksheet,
like fonts and values etc., but it won't change the columnwidth.

I tried these statements and none of them work:
oSheet.Range("A1").Columns.ColumnWidth = 5.75
oSheet.Range("A1").ColumnWidth = 5.75
oSheet.Columns("A:A").ColumnWidth = 5.75

oSheet.Columns("A").Select
Selection.ColumnWidth = 5.75

Does anybody know how to do this?

Any help would be gratefully appreciated.

Thanks,
Tony

Try:

Sheets("oSheet").Columns("A:A").ColumnWidth = 5.75

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default How to change column size in VB6 and Excel 2002

Hello kounoike.

I tried using your code. It works great except that it put a value in cell
A1 of 5.71 and it did not change the column width to 5.75. It makes all of
the other changes for values and fonts, etc., but not the column width.

Thanks,
Tony

"kounoike" wrote:

i tested below in VB6.0 and Excel2003. it could change the column width of a
column, and almost your code also could change the width of column.

Sub testVB6()
Dim oApp As Excel.Application
Dim oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet
Set oApp = New Excel.Application

oApp.Visible = True
On Error Resume Next
Set oBook = oApp.Workbooks.Open("C:\testsample.xls")
If oBook Is Nothing Then
Set oBook = oApp.Workbooks.Add
oBook.SaveAs "C:\testsample.xls"
End If

Set oSheet = oBook.Worksheets(1)
oSheet.Columns("A").ColumnWidth = 5.75
oSheet.Range("A1") = oSheet.Columns("A").ColumnWidth

oApp.DisplayAlerts = False
oBook.Close SaveChanges:=True
Set oSheet = Nothing
Set oBook = Nothing
oApp.Quit
Set oApp = Nothing
End Sub

keiji

"Tony Girgenti" wrote in message
...
Hello.

Using VB6.0 and Excel 2002. I'm trying to change the column width of a
column before saving the workbook. I can do other changes to the
worksheet,
like fonts and values etc., but it won't change the columnwidth.

I tried these statements and none of them work:
oSheet.Range("A1").Columns.ColumnWidth = 5.75
oSheet.Range("A1").ColumnWidth = 5.75
oSheet.Columns("A:A").ColumnWidth = 5.75

oSheet.Columns("A").Select
Selection.ColumnWidth = 5.75

Does anybody know how to do this?

Any help would be gratefully appreciated.

Thanks,
Tony



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default How to change column size in VB6 and Excel 2002

Hello kounoike.

I used your code and it works fine except that it doesn't change the column
width. I makes all of the other changes as far as values and fonts, etc.,
but not the column width. The value of cell A1 is 5.71 and it's width is
5.71.

Thanks,
Tony


"kounoike" wrote:

i tested below in VB6.0 and Excel2003. it could change the column width of a
column, and almost your code also could change the width of column.

Sub testVB6()
Dim oApp As Excel.Application
Dim oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet
Set oApp = New Excel.Application

oApp.Visible = True
On Error Resume Next
Set oBook = oApp.Workbooks.Open("C:\testsample.xls")
If oBook Is Nothing Then
Set oBook = oApp.Workbooks.Add
oBook.SaveAs "C:\testsample.xls"
End If

Set oSheet = oBook.Worksheets(1)
oSheet.Columns("A").ColumnWidth = 5.75
oSheet.Range("A1") = oSheet.Columns("A").ColumnWidth

oApp.DisplayAlerts = False
oBook.Close SaveChanges:=True
Set oSheet = Nothing
Set oBook = Nothing
oApp.Quit
Set oApp = Nothing
End Sub

keiji

"Tony Girgenti" wrote in message
...
Hello.

Using VB6.0 and Excel 2002. I'm trying to change the column width of a
column before saving the workbook. I can do other changes to the
worksheet,
like fonts and values etc., but it won't change the columnwidth.

I tried these statements and none of them work:
oSheet.Range("A1").Columns.ColumnWidth = 5.75
oSheet.Range("A1").ColumnWidth = 5.75
oSheet.Columns("A:A").ColumnWidth = 5.75

oSheet.Columns("A").Select
Selection.ColumnWidth = 5.75

Does anybody know how to do this?

Any help would be gratefully appreciated.

Thanks,
Tony



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default How to change column size in VB6 and Excel 2002

Hi tony

I can change column width in my environment, so i don't have any idea why
you can't change it.
by the way, can you change column width not from VB6 but with Excel VBA?
some code with Excel VBA like this "Columns("A:A").ColumnWidth = 20" could
change the column width of A to 20 on your Excel's activesheet?

keiji

"Tony Girgenti" wrote in message
...
Hello kounoike.

I used your code and it works fine except that it doesn't change the
column
width. I makes all of the other changes as far as values and fonts, etc.,
but not the column width. The value of cell A1 is 5.71 and it's width is
5.71.

Thanks,
Tony


"kounoike" wrote:

i tested below in VB6.0 and Excel2003. it could change the column width
of a
column, and almost your code also could change the width of column.

Sub testVB6()
Dim oApp As Excel.Application
Dim oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet
Set oApp = New Excel.Application

oApp.Visible = True
On Error Resume Next
Set oBook = oApp.Workbooks.Open("C:\testsample.xls")
If oBook Is Nothing Then
Set oBook = oApp.Workbooks.Add
oBook.SaveAs "C:\testsample.xls"
End If

Set oSheet = oBook.Worksheets(1)
oSheet.Columns("A").ColumnWidth = 5.75
oSheet.Range("A1") = oSheet.Columns("A").ColumnWidth

oApp.DisplayAlerts = False
oBook.Close SaveChanges:=True
Set oSheet = Nothing
Set oBook = Nothing
oApp.Quit
Set oApp = Nothing
End Sub

keiji

"Tony Girgenti" wrote in message
...
Hello.

Using VB6.0 and Excel 2002. I'm trying to change the column width of a
column before saving the workbook. I can do other changes to the
worksheet,
like fonts and values etc., but it won't change the columnwidth.

I tried these statements and none of them work:
oSheet.Range("A1").Columns.ColumnWidth = 5.75
oSheet.Range("A1").ColumnWidth = 5.75
oSheet.Columns("A:A").ColumnWidth = 5.75

oSheet.Columns("A").Select
Selection.ColumnWidth = 5.75

Does anybody know how to do this?

Any help would be gratefully appreciated.

Thanks,
Tony






  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default How to change column size in VB6 and Excel 2002

Yes, i created a macro with your statement and it worked fine.

Can you think of any reason why my program will not change the column width?

Thanks,
Tony

"kounoike" wrote:

Hi tony

I can change column width in my environment, so i don't have any idea why
you can't change it.
by the way, can you change column width not from VB6 but with Excel VBA?
some code with Excel VBA like this "Columns("A:A").ColumnWidth = 20" could
change the column width of A to 20 on your Excel's activesheet?

keiji

"Tony Girgenti" wrote in message
...
Hello kounoike.

I used your code and it works fine except that it doesn't change the
column
width. I makes all of the other changes as far as values and fonts, etc.,
but not the column width. The value of cell A1 is 5.71 and it's width is
5.71.

Thanks,
Tony


"kounoike" wrote:

i tested below in VB6.0 and Excel2003. it could change the column width
of a
column, and almost your code also could change the width of column.

Sub testVB6()
Dim oApp As Excel.Application
Dim oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet
Set oApp = New Excel.Application

oApp.Visible = True
On Error Resume Next
Set oBook = oApp.Workbooks.Open("C:\testsample.xls")
If oBook Is Nothing Then
Set oBook = oApp.Workbooks.Add
oBook.SaveAs "C:\testsample.xls"
End If

Set oSheet = oBook.Worksheets(1)
oSheet.Columns("A").ColumnWidth = 5.75
oSheet.Range("A1") = oSheet.Columns("A").ColumnWidth

oApp.DisplayAlerts = False
oBook.Close SaveChanges:=True
Set oSheet = Nothing
Set oBook = Nothing
oApp.Quit
Set oApp = Nothing
End Sub

keiji

"Tony Girgenti" wrote in message
...
Hello.

Using VB6.0 and Excel 2002. I'm trying to change the column width of a
column before saving the workbook. I can do other changes to the
worksheet,
like fonts and values etc., but it won't change the columnwidth.

I tried these statements and none of them work:
oSheet.Range("A1").Columns.ColumnWidth = 5.75
oSheet.Range("A1").ColumnWidth = 5.75
oSheet.Columns("A:A").ColumnWidth = 5.75

oSheet.Columns("A").Select
Selection.ColumnWidth = 5.75

Does anybody know how to do this?

Any help would be gratefully appreciated.

Thanks,
Tony




  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default How to change column size in VB6 and Excel 2002

Sorry, but i have no idea and it's beyond my knowledge.
Show exactly what you did , including your code, then someone else here
could help you.

keiji

"Tony Girgenti" wrote in message
...
Yes, i created a macro with your statement and it worked fine.

Can you think of any reason why my program will not change the column
width?

Thanks,
Tony

"kounoike" wrote:

Hi tony

I can change column width in my environment, so i don't have any idea why
you can't change it.
by the way, can you change column width not from VB6 but with Excel VBA?
some code with Excel VBA like this "Columns("A:A").ColumnWidth = 20"
could
change the column width of A to 20 on your Excel's activesheet?

keiji

"Tony Girgenti" wrote in message
...
Hello kounoike.

I used your code and it works fine except that it doesn't change the
column
width. I makes all of the other changes as far as values and fonts,
etc.,
but not the column width. The value of cell A1 is 5.71 and it's width
is
5.71.

Thanks,
Tony


"kounoike" wrote:

i tested below in VB6.0 and Excel2003. it could change the column
width
of a
column, and almost your code also could change the width of column.

Sub testVB6()
Dim oApp As Excel.Application
Dim oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet
Set oApp = New Excel.Application

oApp.Visible = True
On Error Resume Next
Set oBook = oApp.Workbooks.Open("C:\testsample.xls")
If oBook Is Nothing Then
Set oBook = oApp.Workbooks.Add
oBook.SaveAs "C:\testsample.xls"
End If

Set oSheet = oBook.Worksheets(1)
oSheet.Columns("A").ColumnWidth = 5.75
oSheet.Range("A1") = oSheet.Columns("A").ColumnWidth

oApp.DisplayAlerts = False
oBook.Close SaveChanges:=True
Set oSheet = Nothing
Set oBook = Nothing
oApp.Quit
Set oApp = Nothing
End Sub

keiji

"Tony Girgenti" wrote in message
...
Hello.

Using VB6.0 and Excel 2002. I'm trying to change the column width
of a
column before saving the workbook. I can do other changes to the
worksheet,
like fonts and values etc., but it won't change the columnwidth.

I tried these statements and none of them work:
oSheet.Range("A1").Columns.ColumnWidth = 5.75
oSheet.Range("A1").ColumnWidth = 5.75
oSheet.Columns("A:A").ColumnWidth = 5.75

oSheet.Columns("A").Select
Selection.ColumnWidth = 5.75

Does anybody know how to do this?

Any help would be gratefully appreciated.

Thanks,
Tony





  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default How to change column size in VB6 and Excel 2002

This quote from a KB article *might* help:

XL2000: How to Programmatically Measure the Visible Range in Points
http://support.microsoft.com/kb/213323/en-us
The ColumnWidth property can widen or narrow a column only by a minimum
incremental amount; otherwise the column width does not change. You may need
to experiment with a column to find the smallest amount by which it can be
widened.

Perhaps 5.75 is not attainable based on your worksheet's current
data/format, etc configuration, but a width close to that might be.


--
Tim Zych
SF, CA

"Tony Girgenti" wrote in message
...
Hello.

Using VB6.0 and Excel 2002. I'm trying to change the column width of a
column before saving the workbook. I can do other changes to the
worksheet,
like fonts and values etc., but it won't change the columnwidth.

I tried these statements and none of them work:
oSheet.Range("A1").Columns.ColumnWidth = 5.75
oSheet.Range("A1").ColumnWidth = 5.75
oSheet.Columns("A:A").ColumnWidth = 5.75

oSheet.Columns("A").Select
Selection.ColumnWidth = 5.75

Does anybody know how to do this?

Any help would be gratefully appreciated.

Thanks,
Tony



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
Excel 2002: How to change default page size for printing? Mr. Low Excel Discussion (Misc queries) 3 April 22nd 09 07:01 PM
Change the font size of excel row number and column heading Patty B Excel Discussion (Misc queries) 3 July 3rd 07 07:28 PM
How do I change the size of cells independant from the column poiter Excel Discussion (Misc queries) 1 September 18th 06 07:20 AM
How do you change the size of a range of cells in a column/row SOkoll Charts and Charting in Excel 1 December 8th 04 06:43 AM
Excel 2002 files attached to Outlook 2002 EMails change size AJStadlin Excel Programming 1 October 15th 03 12:12 AM


All times are GMT +1. The time now is 03:17 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"