SAP代码:
data: document type ref to i_oi_document_proxy.
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'.
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
'
' 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

本文详细介绍了如何在SAP系统中调用Excel宏,实现自动化数据处理和报告生成。首先,你需要在SAP中创建一个外部任务,然后指定包含宏的Excel文件路径。接着,设置触发条件,例如定时执行。最后,通过SAP的ABAP编程接口执行Excel宏。此方法极大地提高了工作效率,简化了复杂的数据处理流程。
3483

被折叠的 条评论
为什么被折叠?



