Can't set Excel's ColumnWidth property 
Author Message
 Can't set Excel's ColumnWidth property

It is a VBA problem, in fact. I started a new Excel spreadsheet, placed
a command button in the worksheet and added a line to set the column
width where the active cell belonged so that the code looked like:

Private Sub CommandButton1_Click()
ActiveCell.ColumnWidth = 20
End Sub

When I clicked the button the error popped up:

Run time error '1004'
Unable to set the ColumnWidth Property of the Range Class

It is strange that I have tested this on a computer with both Office 97
and Office 2000 installed. The problem occurred only in Office 97. May I
kow why?

thank you

billy



Thu, 13 Feb 2003 03:00:00 GMT  
 Can't set Excel's ColumnWidth property


Quote:
> It is a VBA problem, in fact. I started a new Excel spreadsheet, placed
> a command button in the worksheet and added a line to set the column
> width where the active cell belonged so that the code looked like:

> Private Sub CommandButton1_Click()
> ActiveCell.ColumnWidth = 20
> End Sub

> When I clicked the button the error popped up:

> Run time error '1004'
> Unable to set the ColumnWidth Property of the Range Class

Off the top of my head, how about

ActiveCell.EntireColumn.ColumnWidth = 20



Fri, 14 Feb 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. 'Canned' data in VB program

2. 'Unread' property not setting correctly

3. setting 'ContactNames' property of olJournalItem

4. Scott's ColumnWidths Sub...

5. Record Set Guru's - Can't Create Record Set error 429

6. Record Set Guru's - Can't Create Record Set error 429

7. Set contol's format property

8. Setting shape custom prop to page's property

9. UserControl can't be selected and properties are not set

10. Can't set XmlElement.Value property

11. Set EmailAddresses property, it's possible?

12. Can't create and set a new custom database property

 

 
Powered by phpBB® Forum Software