Change Text Alignment on Excel

SonicBoomAu

Well-known member
Joined
Oct 30, 2003
Messages
179
Location
Australia
Hi All,

Does anyone know how to change the text alignment for a excel container.
I have tried the following with no joy.

Code:
Dim exc As Excel.Application

exc.Range("B2").HorizontalAlignment = "Center"

My next question is how do I change the width of a column?
 
Managed to find out how to do both.

Code:
        Dim objApp As Excel.Application
        Dim objBook As Excel._Workbook
        Dim objBooks As Excel.Workbooks
        Dim objSheets As Excel.Sheets
        Dim objSheet As Excel._Worksheet
        Dim range As Excel.Range

         Create a new instance of Excel and start a new workbook.
        objApp = New Excel.Application
        objBooks = objApp.Workbooks
        objBook = objBooks.Add
        objSheets = objBook.Worksheets
        objSheet = objSheets(1)

objSheet.PageSetup.Orientation = Excel.XlPageOrientation.xlPortrait

objSheet.Range("B6:E55").HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter

objApp.Columns("A").ColumnWidth = "5"

Resolved
 
Back
Top