SAP 调用EXCEL宏

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

 

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'.
 
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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值