VBSript Excel Center Align / Left Align / Right Align

Call vb script activity can center align cells in an excel file. If Excel is to be used in the processor in real life immediately after the call etc., script activity, a timer should be added (Ex: PT5S).

image

Set objXLApp = CreateObject("Excel.Application")

objXLApp.Visible = false

Set objXLWb = objXLApp.Workbooks.Open("C:\Users\Desktop\Test.xlsx")

Set oSheet = objXLWb.Worksheets(1)

 

oSheet.Range("A1:L45").WrapText = True

oSheet.Columns("A:L").VerticalAlignment   = -4108            

oSheet.Columns("A:L").HorizontalAlignment = -4108                                       

 

objXLWb.save

objXLWb.close false

objXLApp.Quit

 

Set objXLWb = nothing

Set objXLApp = nothing

Justified alignment, right aligns, left align, etc. The following codes can be used to perform operations.

image