2 Replies - 777 Views - Last Post: 14 June 2014 - 12:29 PM Rate Topic: -----

#1 dickvb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-June 14

VB and Excel: changing font and other specs

Posted 14 June 2014 - 11:37 AM

I create and replace Excel files from my VB program.

I successfully change the font specs, but am unable to change the column width.
Here is the code I tried:


excelApp.Visible = True             'if TRUE, won't overwrite older versions
excelWS.Range("A1", "K1").Select
    With Selection.Font
        .Size = 12
        .Bold = True
        .Name = "Garamond"
'        .colWidth = 20
'        .Width = 20
    excelApp.Visible = False             'if TRUE, won't overwrite older versions
    End With



Any ideas about the Column width?
mod: email removed

This post has been edited by modi123_1: 14 June 2014 - 12:13 PM


Is This A Good Question/Topic? 0
  • +

Replies To: VB and Excel: changing font and other specs

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8907
  • View blog
  • Posts: 33,393
  • Joined: 12-June 08

Re: VB and Excel: changing font and other specs

Posted 14 June 2014 - 12:13 PM

Please keep the help on the forum for everyone's benefit. Thanks.
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3180
  • View blog
  • Posts: 10,651
  • Joined: 12-December 12

Re: VB and Excel: changing font and other specs

Posted 14 June 2014 - 12:29 PM

If you record a Macro in Excel you'll get code like this:
Sub Macro1()
'
' Macro1 Macro
'
    Columns("A:A").ColumnWidth = 11
End Sub

If you click into ColumnWidth and press F1 you can then access the help system for this property.

You will have far better success following this sequence than by attempting to guess from VB.

This post has been edited by andrewsw: 14 June 2014 - 12:30 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1