Chinaunix首页 | 论坛 | 博客
  • 博客访问: 392374
  • 博文数量: 66
  • 博客积分: 1235
  • 博客等级: 少尉
  • 技术积分: 694
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-05 12:24
文章分类

全部博文(66)

文章存档

2010年(66)

分类:

2010-09-19 09:46:29

今天好开心,放假在家没事,玩下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
阅读(9518) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

banmahu2010-11-14 22:31:45

CALL METHOD DOCUMENT->EXECUTE_MACRO
            EXPORTING
              MACRO_STRING = '模块2.Macro1'
*                param1       = line_count
*                param_count  = 1
            IMPORTING