繁体   English   中英

如何使用excel VBA将特定值从SAP复制到excel表

[英]How to copy specific value from SAP to excel sheet using excel VBA

我想从 SAP“MMBE”事务中复制 Excel 表中所选材料的库存值:

如果有人可以帮助使用 excel VBA 语法来复制附加快照中突出显示的值。

尽管您可以使用内置 SAP 记录器来记录您的脚本,并且只需单击两次正确的单元格以了解它具有哪些索引,但很难预测列号和名称。 如果您的表彼此不同,它会变得越来越复杂。 您需要首先获取您感兴趣的列名,然后将其与键等进行比较。尝试使用 SAP gui 脚本帮助文件,它就在“SAP 脚本和回放”菜单选项下方。

Public SapGuiAuto
Public SetApp
Public Connection
Public session
Public theCell As String 'may be of anything else you need if casted properly

Sub example()

    Dim nameConstructor As String
    nameConstructor = "          "

    Set SapGuiAuto = GetObject("SAPGUI")
    Set SetApp = SapGuiAuto.GetScriptingEngine
    Set Connection = SetApp.Children(0)
    Set session = Connection.Children(0)

    theCell = session.findById("wnd[0]/usr/cntlCC_CONTAINER/shellcont/shell/shellcont[1]/shell[1]").GetItemText(nameConstructor & "6", "C" & nameConstructor & "1")
    MsgBox theCell
    Cells(1, 1) = theCell

End Sub

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM