![]() |
VBScript to center Text
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? |
VBScript to center Text
You can do the entire sheet with... objWorksheet.Cells.HorizontalAlignment = -4108 --or-- maybe this would be more efficient... objRange1.Cells.HorizontalAlignment = -4108 -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware "jonezn" wrote in message 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? |
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? |
All times are GMT +1. The time now is 01:27 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com