基本的に、VBScriptを使用してセルの中央揃えを設定する方法を知りたい...
私はそれをグーグルで調べてきましたが、役立つものを見つけることができないようです。
Set excel = CreateObject("Excel.Application")
excel.Workbooks.Add() ' create blank workbook
Set workbook = excel.Workbooks(1)
' set A1 to be centered.
workbook.Sheets(1).Cells(1,1).HorizontalAlignment = -4108 ' xlCenter constant.
workbook.SaveAs("C:\NewFile.xls")
excel.Quit()
set excel = nothing
'If the script errors, it'll give you an orphaned excel process, so be warned.
それを .vbs として保存し、コマンド プロンプトまたはダブルクリックを使用して実行します。
セルまたはセルの範囲を選択するには多くの方法がありますが、次の方法は単一のセルに対して機能します。
'Select a Cell Range
Range("D4").Select
'Set the horizontal and vertical alignment
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
HorizontalAlignment オプションは、xlLeft、xlRight、および xlCenter です。