I am trying to export data to an Excel file, which has a title "Application List" placed across cell A1 to cell E1. I want the title to be align in the center rather than in the left.
However, error is found in the indicated line, saying:
"Unable to set the HorizontalAlignment property of the Range class"
Notes: I have tried replacing "xlcenter" in the error line with "xlHAlignCenterAcrossSelection", "xlHAlignCenter", but still can't work.
Following is part of my code:
With xlobj
.Workbooks.Open FileName:=strExcelFile
.Worksheets("Sheet1"
.Select
With .range("A1", "E1"
.Merge
.Value = "Application List"
.Font.Size = 14
.Font.Color = 5
.Font.Bold = True
.Interior.ColorIndex = 24
.HorizontalAlignment = xlcenter <--- Error
.Select
End With
End With
Thank for help in advance.
However, error is found in the indicated line, saying:
"Unable to set the HorizontalAlignment property of the Range class"
Notes: I have tried replacing "xlcenter" in the error line with "xlHAlignCenterAcrossSelection", "xlHAlignCenter", but still can't work.
Following is part of my code:
With xlobj
.Workbooks.Open FileName:=strExcelFile
.Worksheets("Sheet1"
With .range("A1", "E1"
.Merge
.Value = "Application List"
.Font.Size = 14
.Font.Color = 5
.Font.Bold = True
.Interior.ColorIndex = 24
.HorizontalAlignment = xlcenter <--- Error
.Select
End With
End With
Thank for help in advance.