function AutomateExcel()
Dim xlApp, xlBook, xlSheet1 set oXL = CreateObject("EXCEL.APPLICATION")
oXL.Visible = true
set oWB = oXL.Workbooks.Add()
set oSheet = oWB.ActiveSheet
oSheet.Range("A1:A4").Select With oSheet.Range("A1:A4")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
oSheet.Range("A1:A4").Merge
oXL.Visible = true
oXL.UserControl = true
end function
我是用了一个这样的函数,但with里面的内容并没有被执行
Dim xlApp, xlBook, xlSheet1 set oXL = CreateObject("EXCEL.APPLICATION")
oXL.Visible = true
set oWB = oXL.Workbooks.Add()
set oSheet = oWB.ActiveSheet
oSheet.Range("A1:A4").Select With oSheet.Range("A1:A4")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
oSheet.Range("A1:A4").Merge
oXL.Visible = true
oXL.UserControl = true
end function
我是用了一个这样的函数,但with里面的内容并没有被执行
oXL.Selection.Merge();
oXL.Selection.HorizontalAlignment = xlCenter
oXL.Selection.VerticalAlignment = xlBottom
oXL.Selection.WrapText = False
oXL.Selection.Orientation = 0
oXL.Selection.AddIndent = False
oXL.Selection.ShrinkToFit = False
oXL.Selection.MergeCells = False