Sheet1.Cells.HorizontalAlignment = 3'sheet1为sheet对象
Sheet1.Cells.VerticalAlignment = 3

解决方案 »

  1.   

    dim sApp As Excel.Application
    dim sBook As Excel.Workbook
    dim sSheet As Excel.Worksheet
    Set sApp = CreateObject("Excel.Application")
    Set sBook = sApp.Workbooks.Open(XLS文件路径)
    Set sSheet = sBook.Worksheets("sheet1")

    Sheet1.Cells.HorizontalAlignment = 3'ssheet为sheet对象
    Sheet1.Cells.VerticalAlignment = 3
    sApp.DisplayAlerts = False '不提示储存
    sApp.Save
    sBook.Close
    sApp.Quit '强行把Excel给关闭
    Set sSheet = Nothing
    Set sBook = Nothing
    Set sApp = Nothing
      

  2.   

    使用vba有什么问题的不用问别人,自己录制宏然后编辑,看看代码就行了