LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default VBScript to center Text

If
objWorksheet.Cells(1, 7).HorizontalAlignment = -4108
works on a single cell then

objWorksheet.Cells.HorizontalAlignment = -4108
should work on all the cells
--
Gary''s Student


"jonezn" wrote:

I can use this to open the csv file and autofit/sort it. Now how do you
center the entire sheet not just one cell?

Const xlAscending = 1
Const xlYes = 1

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = _
objExcel.Workbooks.Open("h:\Test.csv")


Set objWorksheet = objWorkbook.Worksheets(1)
Set objRange1 = objWorksheet.UsedRange
Set objRange2 = objExcel.Range("A1")
objRange1.Sort objRange2, xlAscending, , , , , , xlYes

Set objRange = objExcel.Columns("A:K").AutoFit

this line does a cell.
objWorksheet.Cells(1, 7).HorizontalAlignment = -4108

how can you do the entire workbook?

 
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
HOW DO I CENTER TEXT WITHIN A CELL? minnie112685 New Users to Excel 1 July 5th 09 06:29 PM
center text Gary''s Student Excel Discussion (Misc queries) 2 May 5th 07 06:26 PM
Center text in dialog box Raza Excel Worksheet Functions 1 December 5th 05 08:34 PM
How to center text in a msgbox Dave_2k5[_3_] Excel Programming 2 July 26th 05 02:31 PM
Creating properly formatted text file from vbscript using excel data msnews.microsoft.com[_7_] Excel Programming 2 December 18th 03 09:33 PM


All times are GMT +1. The time now is 06:50 PM.

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"