今天好开心,放假在家没事,玩下VBA,终于搞定了人生的第一个EXCEL宏,并用SAP正确调用,赞一下
以下为对应代码
SAP代码:
CALL METHOD DOCUMENT->EXECUTE_MACRO
EXPORTING
MACRO_STRING = '模块2.Macro1'
* param1 = line_count
* param_count = 1
IMPORTING
ERROR = ERRORS.
CALL METHOD ERROR->RAISE_MESSAGE
EXPORTING
TYPE = 'E'.
EXCEL宏代码(实现功能给不固定的行加边框):
Sub Macro1()
'
' Macro1 Macro
' 宏由 Alex.Wang 录制,时间: 2010-9-18
'
Dim aa As Integer
' Dim myr%
' aa = Worksheets("PURCHASE ORDER").Range("A18").CurrentRegion.Rows.Count
aa = [b65536].End(xlUp).Row
Range("A17:O" & aa).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
If aa > 17 Then
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End If
End Sub
阅读(9546) | 评论(1) | 转发(0) |